Example #1
0
        /// <summary>
        /// Puts the movie in database.
        /// </summary>
        /// <param name="movieId">The movie identifier.</param>
        /// <returns></returns>
        public async Task <bool> PutMovieInDb(string movieId)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    var model = new InsertModel
                    {
                        UserId     = User.UserId.ToString(),
                        MovieId    = movieId,
                        NewMovie   = "mhmov3jmoaTtkI4mfmD0vxbGPAbt6bggCUchYZRG4Om9", //Sample movie for PUT request(Lord of the Rings: The return of the King). It's a great movie so I'm sure the user don't mind.
                        MovieTitle = "The Lord of the Rings: The Return of the King",
                        ImgRef     = "https://images.mediahound.com/media/mhimgEJ2fdWGaD4D1WqjikaSsR6tVCWM7TDd6wcDorjg.jpg"
                    };

                    var res = await client.PutAsync(_baseUri + "/favorites", SerializeJsonContent(model));

                    return(res.IsSuccessStatusCode);
                }
            }
            catch (HttpRequestException e)
            {
                Debug.WriteLine(e.Message);
                return(false);
            }
        }
 public IHttpActionResult CreateProfile(InsertModel insertModel)
 {
     pCDBContext.AddProfileContact(insertModel.ProfileId, insertModel.Firstname, insertModel.Lastname, insertModel.DOB,
                                   insertModel.ContactId, insertModel.ContactType, insertModel.ContactNumber);
     pCDBContext.SaveChanges();
     return(Ok());
 }
Example #3
0
        public ActionResult InsertMenu(MenuItem _objMenuData)
        {
            InsertModel _model = new InsertModel();

            // _objMenuData.MenuName = _model.MenuName;

            if (ModelState.IsValid && Session["UserName"] != null)
            {
                _objMenuData.IsExists      = true;
                _objMenuData.LastUpdatedBy = Session["UserName"].ToString();
                _objMenuData.LastUpdatedOn = DateTime.Now;

                if (_model.InsertMenu(_objMenuData))
                {
                    TempData["ErrorMessage"] = "Saved";
                }
                else
                {
                    ModelState.AddModelError("", _model.ExceptionMessage);

                    TempData["ErrorMessage"] = _model.ExceptionMessage;
                }

                ModelState.Clear();
            }

            return(View());
        }
Example #4
0
        /// <summary>
        /// Inserts the movie in database.
        /// </summary>
        /// <param name="movieId">The movie identifier.</param>
        /// <returns></returns>
        public async Task <bool> InsertMovieInDb(string movieId, string movieTitle, string imgRef)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    var model = new InsertModel
                    {
                        UserId     = User.UserId.ToString(),
                        MovieId    = movieId,
                        MovieTitle = movieTitle,
                        ImgRef     = imgRef
                    };

                    var res = await client.PostAsync(_baseUri + "/favorites", SerializeJsonContent(model));

                    return(res.IsSuccessStatusCode);
                }
            }
            catch (HttpRequestException e)
            {
                Debug.WriteLine(e.Message);
                return(false);
            }
        }
Example #5
0
        public ActionResult InsertServices(Services _objServiceData)
        {
            InsertModel _model = new InsertModel();

            if (ModelState.IsValid && Session["UserName"] != null)
            {
                _objServiceData.ObjImage.ImageName     = _objServiceData.ServiceName;
                _objServiceData.ObjImage.Description   = "Image is for Services " + _objServiceData.ServiceName;
                _objServiceData.ObjImage.IsExists      = true;
                _objServiceData.ObjImage.LastUpdatedBy = Session["UserName"].ToString();
                _objServiceData.ObjImage.LastUpdatedOn = DateTime.Now;
                _objServiceData.ObjImage.ImageType     = "MainWebsite";

                _objServiceData.IsExists      = true;
                _objServiceData.LastUpdatedBy = Session["UserName"].ToString();
                _objServiceData.LastUpdatedOn = DateTime.Now;

                if (_model.InsertServices(_objServiceData))
                {
                    TempData["ErrorMessage"] = "Saved";
                }
                else
                {
                    ModelState.AddModelError("", _model.ExceptionMessage);

                    TempData["ErrorMessage"] = _model.ExceptionMessage;
                }

                ModelState.Clear();
            }

            return(View());
        }
Example #6
0
        public ActionResult Insert(InsertModel im)
        {
            EditModel pm = null;

            if (im.OriginalId != Guid.Empty)
            {
                pm = EditModel.CreateByOriginalAndPosition(im.OriginalId, im.ParentId, im.Seqno, im.SiteTreeId, im.SiteTree);
            }
            else
            {
                pm = EditModel.CreateByTemplateAndPosition(im.TemplateId, im.ParentId, im.Seqno, im.SiteTreeId, im.SiteTree);
            }

            ViewBag.Title = Piranha.Resources.Page.EditTitleNew + pm.Template.Name.ToLower();

            // Executes the page list loaded hook, if registered
            if (Hooks.Manager.Page.Model.OnLoad != null)
            {
                Hooks.Manager.Page.Model.OnLoad(this, WebPages.Manager.GetActiveMenuItem(), pm);
            }

            if (im.OriginalId != Guid.Empty)
            {
                return(View(@"~/Areas/Manager/Views/Page/EditCopy.cshtml", pm));
            }
            return(View(@"~/Areas/Manager/Views/Page/Edit.cshtml", pm));
        }
        string AgregarAPI(string nombre, string apPat, string apMat, string rfc)
        {
            string Resp = "";

            try
            {
                InsertModel          input          = new InsertModel();
                JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                input.Nombre          = nombre;
                input.ApellidoPaterno = apPat;
                input.ApellidoMaterno = apMat;
                input.RFC             = rfc;

                string Params = jsonSerializer.Serialize(input);
                var    client = new RestClient("https://localhost:44387/api/Personas/");
                client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                request.AddHeader("Content-Type", "application/json");
                request.AddParameter("application/json", Params, ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Resp = "Registro Agregado";
                }
                else
                {
                    Resp = "Algo Salio mal";
                }
            }
            catch (Exception ex) { Resp = "Algo Salio mal"; }
            return(Resp);
        }
Example #8
0
        public ActionResult Insert(InsertModel im)
        {
            EditModel pm = EditModel.CreateByTemplateAndPosition(im.TemplateId, im.ParentId, im.Seqno);

            ViewBag.Title = Piranha.Resources.Page.EditTitleNew + pm.Template.Name.ToLower();

            return(View("Edit", pm));
        }
Example #9
0
        public ActionResult Insert(InsertModel im)
        {
            EditModel pm = EditModel.CreateByTemplate(im.TemplateId);

            ViewBag.Title = Piranha.Resources.Post.EditTitleNew + pm.Template.Name.ToLower();

            return(View("Edit", pm));
        }
Example #10
0
        public ActionResult Index(InsertModel insertModel)
        {
            HttpClient hc = new HttpClient();

            hc.BaseAddress = new Uri("http://localhost:50865/api/values/");
            var insertProfile = hc.PostAsJsonAsync <InsertModel>("CreateProfile", insertModel);

            insertProfile.Wait();
            ViewBag.message = "Profile created successfully..!!";
            return(View());
        }
 public string Post(int id, InsertModel input)
 {
     if (id != 0 && input != null)
     {
         using (PruebaTokaEntities db = new PruebaTokaEntities())
         {
             var resp = db.sp_ActualizarPersonaFisica(id, input.Nombre, input.ApellidoPaterno, input.ApellidoMaterno, input.RFC, input.FechaNacimiento, input.UsuarioAgrega);
             db.SaveChanges();
         }
     }
     return("");
 }
Example #12
0
        //[HttpPost]
        //public ActionResult InsertSocialLinks(HttpPostedFileBase file)
        //{
        //    string filepath = System.IO.Path.GetFileName(file.FileName);
        //    return View();
        //}

        //public ActionResult InsertSocialLinks(SocialLinks objSocialLinks)
        //{
        //    return View();
        //}

        //[HttpPost]
        public ActionResult InsertSocialLinks(HttpPostedFileBase file, SocialLinks objSocialLinks)
        {
            InsertModel _model = new InsertModel();

            if (ModelState.IsValid && Session["UserName"] != null)
            {
                if (file != null && file.ContentLength > 0)
                {
                    string path = Path.Combine(Server.MapPath("~/Content/images/SocialMedia"),
                                               objSocialLinks.LinkType + Path.GetExtension(file.FileName));
                    try
                    {
                        file.SaveAs(path);

                        //string filePath = objSocialLinks.objImage.ImagePath;

                        objSocialLinks.objImage               = new Image();
                        objSocialLinks.objImage.ImagePath     = "Content/images/SocialMedia/" + objSocialLinks.LinkType + Path.GetExtension(file.FileName);
                        objSocialLinks.objImage.ImageName     = objSocialLinks.LinkType;
                        objSocialLinks.objImage.IsExists      = true;
                        objSocialLinks.objImage.LastUpdatedBy = Session["UserName"].ToString();
                        objSocialLinks.objImage.LastUpdatedOn = DateTime.Now;
                        objSocialLinks.objImage.ImageType     = "Social Link Image";
                        objSocialLinks.objImage.Description   = "Social Link Images";

                        objSocialLinks.IsExists      = true;
                        objSocialLinks.LastUpdatedBy = Session["UserName"].ToString();
                        objSocialLinks.LastUpdatedOn = DateTime.Now;

                        if (_model.InsertSocialLinks(objSocialLinks))
                        {
                            TempData["ErrorMessage"] = "Saved";
                        }
                        else
                        {
                            ModelState.AddModelError("", _model.ExceptionMessage);

                            TempData["ErrorMessage"] = _model.ExceptionMessage;
                        }

                        ModelState.Clear();
                    }
                    catch (Exception ex)
                    {
                        FileInfo fileinfo = new FileInfo(path);
                        fileinfo.Delete();
                        ModelState.AddModelError("", ex.Message.ToString());
                    }
                }
            }

            return(View());
        }
Example #13
0
        public ActionResult Insert(InsertModel im)
        {
            EditModel pm = EditModel.CreateByTemplate(im.TemplateId);

            ViewBag.Title = Piranha.Resources.Post.EditTitleNew + pm.Template.Name.ToLower();

            // Executes the post edit loaded hook, if registered
            if (WebPages.Hooks.Manager.PostEditModelLoaded != null)
            {
                WebPages.Hooks.Manager.PostEditModelLoaded(this, WebPages.Manager.GetActiveMenuItem(), pm);
            }

            return(View(@"~/Areas/Manager/Views/Post/Edit.cshtml", pm));
        }
Example #14
0
        public virtual ActionResult Create()
        {
            if (ControllerName.IsNullOrWhiteSpace())
            {
                return(RedirectToAction("Index"));
            }

            var model = new InsertModel()
            {
                ControllerName = ControllerName,
                Title          = ControllerName
            };

            return(View("~/Views/DBObjViews/Shared/Create.cshtml", null, model));
        }
        public string CreateInsertQuery(InsertModel query)
        {
            string result;

            if (query.HasKeyValues)
            {
                result = CreateInsert(query.Table, query.KeyValues);
            }
            else
            {
                result = CreateInsert(query.Table, query.Values);
            }

            return(result);
        }
Example #16
0
        /// <summary>
        /// List转DataTable
        /// </summary>
        /// <param name="InputList">输入的对象列表</param>
        public static DataTable List2DataTable(List <T> InputList, string ColumnDisplayOrder = "")
        {
            DataTable           reVal                  = new DataTable();
            Type                type                   = typeof(T);
            List <PropertyInfo> PropertyArr            = type.GetPropertyList();
            List <string>       ColumnDisplayOrderList = ColumnDisplayOrder.SplitString(",").ToList();
            List <string>       PropertyList           = new List <string>();

            foreach (PropertyInfo PI in PropertyArr)
            {
                if (PI.CanRead)
                {
                    PropertyList.Add(PI.Name);
                }
            }
            if (ColumnDisplayOrder.Length > 0)
            {
                foreach (string ColumnName in ColumnDisplayOrderList)
                {
                    if (ColumnName.In(PropertyList))
                    {
                        reVal.Columns.Add(ColumnName);
                    }
                }
            }

            if (reVal.Columns.Count == 0)
            {
                foreach (string PIN in PropertyList)
                {
                    reVal.Columns.Add(PIN);
                }
            }
            foreach (T InsertModel in InputList)
            {
                DataRow DW = reVal.NewRow();
                foreach (string PIN in PropertyList)
                {
                    DW[PIN] = InsertModel.GetObjectPropertyValue(PIN);
                }
                reVal.Rows.Add(DW);
            }
            return(reVal);
        }
Example #17
0
        public async Task InsertNoPrimaryKey_Failure()
        {
            var model = new InsertModel
            {
                TableName = _tableName,
                Fields    = new List <DynamoField>
                {
                    new DynamoField {
                        ColumnName = "test", ColumnType = ColumnType.String, ColumnValue = "hello2"
                    }
                }
            };

            var response = await _operations.InsertAsync(model);

            Assert.False(response.IsSuccess);
            Assert.Equal(HttpStatusCode.BadRequest, response.HttpStatusCode);
            Assert.Equal("ValidationException", response.ErrorCode);
        }
        public async Task <InsertResponseModel> InsertAsync(InsertModel value)
        {
            var validationResult = _insertValidation.Validate(value);

            if (!validationResult.IsSuccess)
            {
                return(await Task.FromResult((InsertResponseModel)validationResult));
            }

            try
            {
                var dynamoObject = value.Fields.ToDictionary(column => column.ColumnName,
                                                             column => CreateAttributeValue(column.ColumnType, column.ColumnValue));

                var putItemResponse = await Client.PutItemAsync(new PutItemRequest
                {
                    TableName = value.TableName,
                    Item      = dynamoObject
                });

                return(new InsertResponseModel
                {
                    HttpStatusCode = putItemResponse.HttpStatusCode
                });
            }
            catch (AmazonDynamoDBException exception)
            {
                return(new InsertResponseModel
                {
                    HttpStatusCode = exception.StatusCode,
                    ErrorCode = exception.ErrorCode,
                    ErrorMessage = exception.Message
                });
            }
            catch (Exception exception)
            {
                return(new InsertResponseModel
                {
                    ErrorMessage = exception.ToString()
                });
            }
        }
Example #19
0
        public async Task InsertNoTableName_Failure()
        {
            var model = new InsertModel
            {
                Fields = new List <DynamoField>
                {
                    new DynamoField {
                        ColumnName = "id", ColumnType = ColumnType.Number, ColumnValue = "1"
                    },
                    new DynamoField {
                        ColumnName = "test", ColumnType = ColumnType.String, ColumnValue = "hello2"
                    }
                }
            };

            var response = await _operations.InsertAsync(model);

            Assert.False(response.IsSuccess);
            Assert.Equal("Table name cannot be empty", response.ErrorMessage);
        }
Example #20
0
        public async Task InsertValidOperation_Success()
        {
            var model = new InsertModel
            {
                TableName = _tableName,
                Fields    = new List <DynamoField>
                {
                    new DynamoField {
                        ColumnName = "id", ColumnType = ColumnType.Number, ColumnValue = "1"
                    },
                    new DynamoField {
                        ColumnName = "test", ColumnType = ColumnType.String, ColumnValue = "hello2"
                    }
                }
            };

            var response = await _operations.InsertAsync(model);

            Assert.True(response.IsSuccess);
        }
Example #21
0
        public virtual ActionResult Create(FormCollection collection)
        {
            try
            {
                var dto = GetDtoFromCollection(0, collection);
                try
                {
                    BusinessLayer.Insert((T)dto);

                    var model = new InsertModel(InsertModel.History.Message, "Successfully inserted data!", dto)
                    {
                        ControllerName = ControllerName,
                        Title          = ControllerName
                    };

                    return(View("~/Views/DbObjViews/Shared/Create.cshtml", null, model));
                }
                catch (Exception e)
                {
                    var model = new InsertModel(InsertModel.History.Error, e.Message, dto)
                    {
                        ControllerName = ControllerName,
                        Title          = ControllerName
                    };
                    return(View("~/Views/DbObjViews/Shared/Create.cshtml", null, model));
                }
            }
            catch (FormatException e)
            {
                throw new Exception("Could not convert form-data to object. Please check HTML form!" + e.Message, e);
            }
            catch (Exception e)
            {
                var model = new InsertModel(InsertModel.History.Error, e.Message)
                {
                    ControllerName = ControllerName,
                    Title          = ControllerName
                };
                return(View("~/Views/DbObjViews/Shared/Create.cshtml", null, model));
            }
        }
Example #22
0
        /// <summary>
        /// Serializes the model into a json format and return it as stringcontent.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        private static StringContent SerializeJsonContent(InsertModel model)
        {
            var json = JsonConvert.SerializeObject(model);

            return(new StringContent(json, Encoding.UTF8, "application/json"));
        }
Example #23
0
        public ActionResult Portfolio(HttpPostedFileBase file, Portfolio objPortfolio)
        {
            InsertModel _model = new InsertModel();

            ReadModel _readModel = new ReadModel();

            List <Services> _lstServices = _readModel.ReadServices();

            List <SelectListItem> list = new List <SelectListItem>();
            var servlst = (from c in _lstServices select c).ToArray();

            for (int i = 0; i < servlst.Length; i++)
            {
                list.Add(new SelectListItem
                {
                    Text  = servlst[i].ServiceName,
                    Value = servlst[i].ServiceId.ToString(),
                });
            }
            ViewData["ServiceLst"] = list;

            if (ModelState.IsValid && Session["UserName"] != null)
            {
                try
                {
                    if (file != null && file.ContentLength > 0)
                    {
                        string ImageName = objPortfolio.Title + "-" + objPortfolio.ServiceId + Path.GetExtension(file.FileName);

                        string path = Path.Combine(Server.MapPath("~/Content/images/Portfolio"),
                                                   ImageName);

                        file.SaveAs(path);

                        if (!objPortfolio.Link.StartsWith("http"))
                        {
                            string Link = objPortfolio.Link;
                            objPortfolio.Link = "http://" + Link;
                        }


                        objPortfolio.objImage           = new Image();
                        objPortfolio.objImage.ImagePath = "Content/images/Portfolio/" + ImageName;

                        objPortfolio.objImage.ImageName     = objPortfolio.Title;
                        objPortfolio.objImage.Description   = "Image is for Portfolio " + objPortfolio.Title;
                        objPortfolio.objImage.IsExists      = true;
                        objPortfolio.objImage.LastUpdatedBy = Session["UserName"].ToString();
                        objPortfolio.objImage.LastUpdatedOn = DateTime.Now;
                        objPortfolio.objImage.ImageType     = "PortfolioImage";

                        //objPortfolio.objServices = new Services();
                        //objPortfolio.objServices.ServiceId = objPortfolio.ServiceId;

                        objPortfolio.IsExists      = true;
                        objPortfolio.LastUpdatedBy = Session["UserName"].ToString();
                        objPortfolio.LastUpdatedOn = DateTime.Now;

                        if (_model.InsertPortfolio(objPortfolio))
                        {
                            TempData["ErrorMessage"] = "Saved";
                        }
                        else
                        {
                            ModelState.AddModelError("", _model.ExceptionMessage);

                            TempData["ErrorMessage"] = _model.ExceptionMessage;
                        }

                        ModelState.Clear();
                    }
                }
                catch (Exception exp)
                {
                    ModelState.AddModelError("Error in Inserting Portfolio", exp.Message.ToString());
                }
            }

            return(View());
        }
Example #24
0
        public ActionResult InsertContacts(Contacts _objContactData)
        {
            InsertModel _model = new InsertModel();

            if (ModelState.IsValid && Session["UserName"] != null)
            {
                _objContactData.LstContactInfo[0].ContactType = "WebsiteUrl";
                _objContactData.LstContactInfo[0].Preference  = "1";
                // _objContactData.LstContactInfo[0].Value = _objContactData.LstContactInfo[0].Value;
                _objContactData.LstContactInfo[0].Description   = "Work";
                _objContactData.LstContactInfo[0].LastUpdatedOn = DateTime.Now;
                _objContactData.LstContactInfo[0].LastUpdatedBy = Session["UserName"].ToString();
                _objContactData.LstContactInfo[0].IsExists      = true;



                _objContactData.LstContactInfo[1].ContactType = "Phone";
                _objContactData.LstContactInfo[1].Preference  = "1";
                //_objContactData.LstContactInfo[1].Value = _objContactData.LstContactInfo[1].Value;
                _objContactData.LstContactInfo[1].Description   = _objContactData.LstContactInfo[1].Description;
                _objContactData.LstContactInfo[1].LastUpdatedOn = DateTime.Now;
                _objContactData.LstContactInfo[1].LastUpdatedBy = Session["UserName"].ToString();
                _objContactData.LstContactInfo[1].IsExists      = true;


                _objContactData.LstContactInfo[2].ContactType = "Email";
                _objContactData.LstContactInfo[2].Preference  = "1";
                // _objContactData.LstContactInfo[2].Description = _objContactData.LstContactInfo[2].Description;
                _objContactData.LstContactInfo[2].Value         = _objContactData.LstContactInfo[2].Value;
                _objContactData.LstContactInfo[2].LastUpdatedOn = DateTime.Now;
                _objContactData.LstContactInfo[2].LastUpdatedBy = Session["UserName"].ToString();
                _objContactData.LstContactInfo[2].IsExists      = true;


                //_objContactData.LstContactInfo[0].ContactType = "WebsiteUrl";
                //_objContactData.LstContactInfo[0].Preference = "1";

                //_objContactData.LstContactInfo[1].ContactType = "Phone";
                //_objContactData.LstContactInfo[1].Preference = "1";

                //_objContactData.LstContactInfo[3].ContactType = "Email";
                //_objContactData.LstContactInfo[3].Preference = "1";
                _objContactData.IsExists      = true;
                _objContactData.LastUpdatedBy = Session["UserName"].ToString();
                _objContactData.LastUpdatedOn = DateTime.Now;

                if (_model.InsertContacts(_objContactData))
                {
                    TempData["ErrorMessage"] = "Saved";
                }
                else
                {
                    ModelState.AddModelError("", _model.ExceptionMessage);

                    TempData["ErrorMessage"] = _model.ExceptionMessage;
                }

                ModelState.Clear();
            }

            return(View());
        }