Exemplo n.º 1
0
        public ActionResult CopyOnboardTab(int onboardid, List <string> facilities)
        {
            try
            {
                var model = _OnBoardedServices.GetDetailForOnboarded(onboardid);

                foreach (var item in facilities)
                {
                    Onboarded On_boarded = new Onboarded();
                    var       sortnum    = _OnBoardedServices.GetSortNumMaxByFacility(item);
                    On_boarded.ParameterName       = model.ParameterName;
                    On_boarded.ParameterName_Info  = model.ParameterName_Info;
                    On_boarded.ParameterName_Image = model.ParameterName_Image;
                    On_boarded.Facility_Name       = _facilityService.GetFacilityName(item);
                    On_boarded.Facility_Id         = item;
                    On_boarded.Parameter_Add_Date  = DateTime.Now.ToEST();
                    On_boarded.SortNum             = sortnum == null ? 1 : sortnum + 1;
                    _OnBoardedServices.Create(On_boarded);
                }
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public ActionResult EditOnboarded(int id)
        {
            if (id == null)
            {
                new SelectListItem {
                };
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Onboarded model = _OnBoardedServices.GetDetails(id);

            ViewBag.Facilities = _lookUpService.GetAllFacility(null)
                                 .Select(m => new { Value = m.fac_key, Text = m.fac_name })
                                 .ToList()
                                 .Select(m => new SelectListItem {
                Value = m.Value.ToString(), Text = m.Text
            });
            ViewBag.Fac_Id = model.Facility_Id;

            if (model == null)
            {
                return(HttpNotFound());
            }
            //return GetViewResult(onboarded);
            var result = RenderPartialViewToString("EditOnboarded", model);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
 public bool Delete(Onboarded entity)
 {
     _unitOfWork.OnBoardedRepository.Delete(entity.Onboarded_ID);
     _unitOfWork.Save();
     _unitOfWork.Commit();
     return(true);
 }
Exemplo n.º 4
0
        public ActionResult EditButton(string fac_key)
        {
            Onboarded model = new Onboarded();

            ViewBag.fac_keys   = fac_key;
            ViewBag.Facilities = _lookUpService.GetAllFacility(null)
                                 .Select(m => new { Value = m.fac_key, Text = m.fac_name })
                                 .ToList()
                                 .Select(m => new SelectListItem {
                Value = m.Value.ToString(), Text = m.Text
            }).Where(x => x.Value != fac_key);
            var result = RenderPartialViewToString("EditButton", model);

            return(Json(new { success = true, data = result }));
            //return GetViewResult();
        }
Exemplo n.º 5
0
 public ActionResult AddNewfacility(string cas_fac_key_arrays, string cas_fac_Name_array, string current_fac_key)
 {
     try
     {
         foreach (var item2 in cas_fac_key_arrays.Split(','))
         {
             var getDetails = _OnBoardedServices.GetAllBoardedData(item2);
             if (getDetails != null)
             {
                 var result = _OnBoardedServices.DeleteRange(getDetails);
             }
         }
         Onboarded On_boarded = new Onboarded();
         var       lsit       = _OnBoardedServices.GetAllBoardedData(current_fac_key);
         foreach (var item in lsit)
         {
             foreach (var item2 in cas_fac_key_arrays.Split(','))
             {
                 var sortnum = _OnBoardedServices.GetSortNumMaxByFacility(item2);
                 On_boarded.ParameterName       = item.ParameterName;
                 On_boarded.ParameterName_Info  = item.ParameterName_Info;
                 On_boarded.ParameterName_Image = item.ParameterName_Image;
                 On_boarded.Facility_Name       = _facilityService.GetFacilityName(item2);
                 On_boarded.Facility_Id         = item2;
                 On_boarded.Parameter_Add_Date  = DateTime.Now.ToEST();
                 On_boarded.SortNum             = sortnum == null ? 1 : sortnum + 1;
                 _OnBoardedServices.Create(On_boarded);
             }
         }
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                               eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                   ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
     //return GetViewResult();
 }
Exemplo n.º 6
0
        public ActionResult CreateOnboarded(string fac_key, string issave)
        {
            ViewBag.fac_keys = fac_key;
            ViewBag.issaves  = issave;
            Onboarded model = new Onboarded();

            ViewBag.Facilities = _lookUpService.GetAllFacility(null)
                                 .Select(m => new { Value = m.fac_key, Text = m.fac_name })
                                 .ToList()
                                 .Select(m => new SelectListItem {
                Value = m.Value.ToString(), Text = m.Text
            });

            var onboardingdetails = _OnBoardedServices.GetDetailsForPOpUP(fac_key);

            ViewBag.onboardingdatas = onboardingdetails;

            ViewBag.FAC_value = TempData["message"];
            var result = RenderPartialViewToString("CreateOnboarded", model);

            return(Json(new { success = true, data = result }));
            //return GetViewResult(_Onboarding);
        }
Exemplo n.º 7
0
        public ActionResult Upload(string ParameterName, string parameterinfo, string cas_fac_key_arrays, string cas_fac_Name_array, string Div_Image)
        {
            Onboarded On_boardeds = new Onboarded();

            try
            {
                string connString      = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
                var    connStringArray = connString.Split(';');
                var    dictionary      = new Dictionary <string, string>();
                foreach (var item in connStringArray)
                {
                    var itemKeyValue = item.Split('=');
                    dictionary.Add(itemKeyValue[0], itemKeyValue[1]);
                }
                string accountname = dictionary["AccountName"];
                string accesskeys  = dictionary["AccountKey"];
                string accesskey   = accesskeys + "==";
                string Imagepath   = "";

                foreach (var items in Div_Image.Split(','))
                {
                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        var file = Request.Files[i];
                        if (file.FileName.Equals(items))
                        {
                            var fileName = DateTime.Now.ToString("yyyymmddMMssfff") + System.IO.Path.GetExtension(file.FileName);
                            var path     = Path.Combine(Server.MapPath("~/Content/"), fileName);
                            var imagepth = path;
                            file.SaveAs(path);
                            string              BlobKey            = WebConfigurationManager.AppSettings["BlobStroageKey"];
                            var                 OrigionalImagepath = BlobKey + fileName;
                            StorageCredentials  creden             = new StorageCredentials(accountname, accesskey);
                            CloudStorageAccount acc    = new CloudStorageAccount(creden, useHttps: true);
                            CloudBlobClient     client = acc.CreateCloudBlobClient();
                            CloudBlobContainer  cont   = client.GetContainerReference("onboarding");
                            cont.CreateIfNotExists();
                            cont.SetPermissions(new BlobContainerPermissions
                            {
                                PublicAccess = BlobContainerPublicAccessType.Blob
                            });
                            CloudBlockBlob cblob          = cont.GetBlockBlobReference(fileName);
                            var            LocalImagePath = path.ToString();
                            using (Stream ddd = System.IO.File.OpenRead(@LocalImagePath))

                            {
                                cblob.UploadFromStream(ddd);
                            }
                            Imagepath += OrigionalImagepath + ",";
                            if (System.IO.File.Exists(path))
                            {
                                System.IO.File.Delete(path);
                            }
                        }
                    }
                }
                foreach (var item in cas_fac_key_arrays.Split(','))
                {
                    var sortnum      = _OnBoardedServices.GetSortNumMaxByFacility(item);
                    var encode_value = Functions.DecodeFrom64(parameterinfo);
                    On_boardeds.ParameterName       = ParameterName;
                    On_boardeds.ParameterName_Info  = encode_value;
                    On_boardeds.ParameterName_Image = Imagepath;
                    On_boardeds.Facility_Name       = _facilityService.GetFacilityName(item);
                    On_boardeds.Facility_Id         = item;
                    On_boardeds.Parameter_Add_Date  = DateTime.Now.ToEST();
                    On_boardeds.SortNum             = sortnum == null ? 1 : sortnum + 1;
                    _OnBoardedServices.Create(On_boardeds);
                }
                TempData["message"] = cas_fac_key_arrays;
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }

            return(ShowSuccessMessageOnly("OnBoarding SuccessFuly Added.", On_boardeds));
        }
Exemplo n.º 8
0
        public ActionResult EditOnboarded(string ParameterName, string parameterinfo, string FacilityIdss, string FacilityNames, string onid, string OldImagePath, string Div_Image, int SortNum)
        {
            try
            {
                Onboarded On_boardeds      = new Onboarded();
                string    savenewimagepath = "";
                string    connString       = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
                var       connStringArray  = connString.Split(';');
                var       dictionary       = new Dictionary <string, string>();
                foreach (var item in connStringArray)
                {
                    var itemKeyValue = item.Split('=');
                    dictionary.Add(itemKeyValue[0], itemKeyValue[1]);
                }
                string accountname = dictionary["AccountName"];
                string accesskeys  = dictionary["AccountKey"];
                string accesskey   = accesskeys + "==";
                var    onboarded   = _OnBoardedServices.GetDetails(Convert.ToInt32(onid));
                On_boardeds = onboarded;
                var onboardedimges = onboarded.ParameterName_Image;

                foreach (var img in Div_Image.Split(','))
                {
                    foreach (var item in onboardedimges.Split(','))
                    {
                        if (img == item)
                        {
                            var imgpathbydb = item;
                            savenewimagepath += imgpathbydb + ",";
                            break;
                        }
                    }
                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        var file = Request.Files[i];
                        if (file.FileName == img)
                        {
                            var fileName = DateTime.Now.ToString("yyyymmddMMssfff") + System.IO.Path.GetExtension(file.FileName);
                            var path     = Path.Combine(Server.MapPath("~/Content/"), fileName);
                            var imagepth = path;
                            file.SaveAs(path);
                            string              BlobKey            = WebConfigurationManager.AppSettings["BlobStroageKey"];
                            var                 OrigionalImagepath = BlobKey + fileName;
                            StorageCredentials  creden             = new StorageCredentials(accountname, accesskey);
                            CloudStorageAccount acc    = new CloudStorageAccount(creden, useHttps: true);
                            CloudBlobClient     client = acc.CreateCloudBlobClient();
                            CloudBlobContainer  cont   = client.GetContainerReference("onboarding");
                            cont.CreateIfNotExists();
                            cont.SetPermissions(new BlobContainerPermissions
                            {
                                PublicAccess = BlobContainerPublicAccessType.Blob
                            });
                            CloudBlockBlob cblob          = cont.GetBlockBlobReference(fileName);
                            var            LocalImagePath = path.ToString();
                            using (Stream ddd = System.IO.File.OpenRead(@LocalImagePath))

                            {
                                cblob.UploadFromStream(ddd);
                            }
                            savenewimagepath += OrigionalImagepath + ",";
                            if (System.IO.File.Exists(path))
                            {
                                System.IO.File.Delete(path);
                            }
                            //newImagesLink = savenewimagepath;
                            break;
                        }
                    }
                }
                var getRecord  = _OnBoardedServices.GetDetailsForPOpUP(FacilityIdss);
                int?highestnum = getRecord.Max(x => x.SortNum);
                if (SortNum > highestnum)
                {
                    SortNum = Convert.ToInt32(highestnum);
                }
                else if (SortNum < 1)
                {
                    SortNum = 1;
                }
                int onboardid  = Convert.ToInt32(onid);
                int?oldsortnum = getRecord.Where(x => x.Onboarded_ID == onboardid).Select(x => x.SortNum).FirstOrDefault();
                if (oldsortnum != SortNum)
                {
                    foreach (var item in getRecord)
                    {
                        if (item.Onboarded_ID != onboardid)
                        {
                            var detail = _OnBoardedServices.GetDetails(item.Onboarded_ID);
                            if (oldsortnum > SortNum)
                            {
                                if (detail.SortNum >= SortNum && detail.SortNum <= oldsortnum)
                                {
                                    detail.SortNum = detail.SortNum + 1;
                                    _OnBoardedServices.Edit(detail);
                                }
                            }
                            else
                            {
                                if (detail.SortNum >= oldsortnum && detail.SortNum <= SortNum)
                                {
                                    detail.SortNum = detail.SortNum - 1;
                                    _OnBoardedServices.Edit(detail);
                                }
                            }
                        }
                    }
                }

                On_boardeds.Onboarded_ID  = Convert.ToInt32(onid);
                On_boardeds.ParameterName = ParameterName;
                var encode_value = Functions.DecodeFrom64(parameterinfo);
                On_boardeds.ParameterName_Info  = encode_value;
                On_boardeds.ParameterName_Image = savenewimagepath;
                On_boardeds.Facility_Name       = FacilityNames;
                On_boardeds.Facility_Id         = FacilityIdss;
                On_boardeds.Parameter_Add_Date  = DateTime.Now.ToEST();
                On_boardeds.SortNum             = SortNum;
                _OnBoardedServices.Edit(On_boardeds);
                ViewBag.Fac_Id = FacilityIdss;
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }


            return(Json(new { success = true, message = "OnBoarded SuccessFuly Added." }));
        }
Exemplo n.º 9
0
 public void Edit(Onboarded entity)
 {
     _unitOfWork.OnBoardedRepository.Update(entity);
     _unitOfWork.Save();
     _unitOfWork.Commit();
 }
Exemplo n.º 10
0
 public void Create(Onboarded entity)
 {
     _unitOfWork.OnBoardedRepository.Insert(entity);
     _unitOfWork.Save();
     _unitOfWork.Commit();
 }