예제 #1
0
        public bool InsertBrandingTeamInfo(tblBrandingTeam brandingTeam)
        {
            try
            {
                _entities.tblBrandingTeams.Add(brandingTeam);
                _entities.SaveChanges();

                return(true);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
예제 #2
0
        public bool InsertNewBrandOutletMasterDetailsInfo(List <NewBrandOutletModel> newBrandOutlet, Guid?tokenNumber)
        {
            try
            {
                using (var entity = new BrandOutletMonitoringEntities())
                {
                    foreach (var newBrandOutletModel in newBrandOutlet)
                    {
                        var outletMaster = new BrandOutletDetail();
                        outletMaster.BrandOutletToken     = tokenNumber;
                        outletMaster.RetailerId           = newBrandOutletModel.RetailerId;
                        outletMaster.BrandCategoryId      = newBrandOutletModel.BrandCategoryId;
                        outletMaster.BrandCategoryName    = newBrandOutletModel.BrandCategoryName;
                        outletMaster.BrandSubCategoryId   = newBrandOutletModel.BrandSubCategoryId;
                        outletMaster.BrandSubCategoryName = newBrandOutletModel.BrandSubCategoryName;
                        outletMaster.Quantity             = newBrandOutletModel.Quantity;
                        outletMaster.AddedBy     = 1;
                        outletMaster.AddedDate   = DateTime.Now;
                        outletMaster.UpdatedBy   = 1;
                        outletMaster.UpdatedDate = DateTime.Now;

                        entity.BrandOutletDetails.Add(outletMaster);
                    }

                    entity.SaveChanges();
                }

                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
예제 #3
0
        public bool InsertNewBrandOutletMasterInfo(List <NewBrandOutletModel> newBrandOutlet, Guid?tokenNumber)
        {
            try
            {
                using (var entity = new BrandOutletMonitoringEntities())
                {
                    var outletMaster = new BrandOutletMaster();
                    outletMaster.OutletToken     = tokenNumber;
                    outletMaster.RetailerId      = newBrandOutlet[0].RetailerId;
                    outletMaster.RetailerName    = newBrandOutlet[0].RetailerName;
                    outletMaster.RetailerAddress = newBrandOutlet[0].RetailerAddress;
                    outletMaster.RetailerPhone   = newBrandOutlet[0].RetailerPhone;
                    outletMaster.AddedBy         = 1;
                    outletMaster.Active          = true;
                    outletMaster.AddedDate       = DateTime.Now;
                    entity.BrandOutletMasters.Add(outletMaster);



                    entity.SaveChanges();
                }

                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
        public bool InsertBrandingIssueSolvedInfo(BrandingIssuesSolved brandingIssue)
        {
            try
            {
                _entities.BrandingIssuesSolveds.Add(brandingIssue);
                _entities.SaveChanges();


                return(true);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                EntityDispose();
            }
        }
예제 #5
0
        //private readonly BrandOutletMonitoringEntities _entities = new BrandOutletMonitoringEntities();
        public bool InsertBrandMonitorCategoryInfo(BrandMonitorCategory brandInfo)
        {
            try
            {
                _entities.BrandMonitorCategories.Add(brandInfo);
                _entities.SaveChanges();


                return(true);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
예제 #6
0
        public bool InsertImage(ImageViewModel model)
        {
            var file = model.ImageFile;

            byte[] imagebyte = null;
            if (file != null)
            {
                BinaryReader reader = new BinaryReader(file.InputStream);
                imagebyte = reader.ReadBytes(file.ContentLength);
                tblImageUploader img = new tblImageUploader();
                img.ImageTitle = file.FileName;
                img.ImageByte  = imagebyte;

                _entities.tblImageUploaders.Add(img);
                _entities.SaveChanges();


                return(true);
            }
            return(true);
        }
예제 #7
0
        public bool UpdateBrandOutletMasterDetailsInfo(List <NewBrandOutletModel> reBrandItems)
        {
            try
            {
                using (var entity = new BrandOutletMonitoringEntities())
                {
                    foreach (var items in reBrandItems)
                    {
                        var shopInfoes = entity.BrandOutletDetails.FirstOrDefault(x => x.BrandOutletToken == items.Token &&
                                                                                  x.BrandCategoryId == items.BrandCategoryId && x.BrandSubCategoryId == items.BrandSubCategoryId);
                        if (shopInfoes != null)
                        {
                            if (items.Quantity != 0)
                            {
                                shopInfoes.Quantity = items.Quantity;
                            }


                            shopInfoes.UpdatedBy   = 1;
                            shopInfoes.UpdatedDate = DateTime.Now;


                            entity.Entry(shopInfoes).State = EntityState.Modified;
                        }


                        entity.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }


            return(true);
        }
예제 #8
0
        public int UploadImageInDataBase(HttpPostedFileBase file, BrandingIssue contentViewModel)
        {
            var _entities = new BrandOutletMonitoringEntities();
            //contentViewModel.IssueFile = ConvertToBytes(file);
            var Content = new BrandingIssue
            {
                //BrandId = contentViewModel.BrandId,
                //Description = contentViewModel.Description,
                //SubCategoryid = contentViewModel.SubCategoryid,
                IssueFile = contentViewModel.IssueFile
            };

            _entities.BrandingIssues.Add(Content);
            int i = _entities.SaveChanges();

            if (i == 1)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
예제 #9
0
        public Result PostDescription()
        {
            var masterResult = new Result();
            var result       = new Result();

            var brandingIssue       = new BrandingIssue();
            var brandingIssueMaster = new BrandIssueMaster();

            const string initialPath = @"~/Content/UploadImage";


            try
            {
                //****Posted Files
                //****Posted Files

                var httpPostedFile = HttpContext.Current.Request.Files;
// ReSharper disable once AssignNullToNotNullAttribute
                var strings             = HttpContext.Current.Request.Form.GetValues("desc").ToList();
                var stringsAddress      = HttpContext.Current.Request.Form.GetValues("add");
                var stringPhone         = HttpContext.Current.Request.Form.GetValues("phone");
                var stringSubcategoryId = HttpContext.Current.Request.Form.GetValues("subcategoryid");
                var stringCategoryId    = HttpContext.Current.Request.Form.GetValues("categoryid");

                //Strings Bind

                //string bind

                string description = null;
                string address     = null;
                string phone       = null;

                long?categoryid    = null;
                long?subcategoryid = null;
                if (strings != null)
                {
                    description = strings[0];
                }

                if (stringsAddress != null)
                {
                    address = stringsAddress[0];
                }

                if (stringPhone != null)
                {
                    phone = stringPhone[0];
                }

                if (stringSubcategoryId != null)
                {
                    subcategoryid = Convert.ToInt64(stringSubcategoryId[0]);
                }

                if (stringCategoryId != null)
                {
                    categoryid = Convert.ToInt64(stringCategoryId[0]);
                }



                //****Posted Files
                //****Posted Files
                // Get the uploaded image from the Files collection
                // Get the uploaded image from the Files collection
                var bmEntity = new BrandOutletMonitoringEntities();

                var issueToken = Guid.NewGuid();


                brandingIssueMaster.IssueId          = issueToken;
                brandingIssueMaster.CategoryId       = categoryid;
                brandingIssueMaster.SubCategoryId    = subcategoryid;
                brandingIssueMaster.Description      = description;
                brandingIssueMaster.RetailersPhone   = phone;
                brandingIssueMaster.RetailersAddress = address;
                brandingIssueMaster.Active           = true;
                brandingIssueMaster.AddedDate        = DateTime.Now;

                bmEntity.BrandIssueMasters.Add(brandingIssueMaster);
                masterResult.issuccess = bmEntity.SaveChanges();
                if (masterResult.issuccess == 1)
                {
                    result.error   = false;
                    result.message = "Uploaded Successfully";

                    if (HttpContext.Current.Request.Files.AllKeys.Any())
                    {
                        for (var iCnt = 0; iCnt <= httpPostedFile.Count - 1; iCnt++)
                        {
                            var postedFile = httpPostedFile[iCnt];

                            var fileName = Path.GetFileName(postedFile.FileName);


                            if (fileName != null)
                            {
                                var todayTime = DateTime.Now;
                                var time      = new DateTime(todayTime.Year, todayTime.Month, todayTime.Day,
                                                             todayTime.Hour,
                                                             todayTime.Minute, todayTime.Second, todayTime.Millisecond);
                                var timeFormat = string.Format("{0:yyyy-MM-dd_hh-mm-ss-fff}", time);
                                fileName = timeFormat + "-" + fileName;
                                var path = Path.Combine(HttpContext.Current.Server.MapPath(initialPath), fileName);
                                postedFile.SaveAs(path);


                                string finalPath = @"C:\uploads" + @"\" + 1 + @"\" + 2 + @"\" + 3;
                                if (Directory.Exists(finalPath))
                                {
                                    File.Copy(path, finalPath + "\\" + fileName, true);
                                }
                                else
                                {
                                    Directory.CreateDirectory(finalPath);
                                    File.Copy(path, finalPath + "\\" + fileName, true);
                                }

                                brandingIssue.BrandIssueId = issueToken;
                                brandingIssue.IssueFile    = finalPath + "\\" + fileName;
                                bmEntity.BrandingIssues.Add(brandingIssue);
                                bmEntity.SaveChanges();

                                result.error   = false;
                                result.message = "Uploaded Successfully";
                            }
                        }
                    }
                }

                else
                {
                    result.error   = true;
                    result.message = "Uploaded Failed";
                }


                //var httpPostedFile = HttpContext.Current.Request.Files["upload"];
                //
            }
            catch (Exception)
            {
                result.error   = true;
                result.message = "Uploaded Failed";
            }


            return(result);
        }