Esempio n. 1
0
        public JsonResult EditHoliday(UserHoliydayviewModel item)
        {
            try
            {
                var holiday = _db.UserProfileHolidays.Find(item.Id);
                if (holiday != null && holiday.Status != (int)GeneralEnums.StatusEnum.Deleted)
                {
                    holiday.Description = item.Description;
                    holiday.HolidayDate = item.HolidayDate;

                    _db.Entry(holiday).State = EntityState.Modified;
                    _db.SaveChanges();

                    var userHolidays = _db.UserProfileHolidays.Where(r => r.UserProfileId == holiday.UserProfileId && r.Status != (int)GeneralEnums.StatusEnum.Deleted);
                    item.UserHolidays = userHolidays.ToList().Select(r => new UserHoliydayviewModel()
                    {
                        Id          = r.Id,
                        Description = r.Description,
                        HolidayDate = r.HolidayDate
                    }).ToList();
                }

                return(Json(item, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.LogException(User.Identity.Name, ex, "Error While editing profile (Post)");
                return(null);
            }
        }
Esempio n. 2
0
        public JsonResult EditPermission(PermissionViewModel permission)
        {
            try
            {
                var permiss = _db.Permissions.Find(permission.Id);
                if (permiss != null && permiss.Status != (int)GeneralEnums.StatusEnum.Deleted)
                {
                    permiss.Status           = permission.Status;
                    permiss.PageUrl          = permission.PageUrl ?? string.Empty;
                    permiss.Description      = permission.Description;
                    permiss.PageName         = permission.PageName;
                    permiss.PermissionKey    = permission.PermissionKey;
                    _db.Entry(permiss).State = EntityState.Modified;
                    _db.SaveChanges();

                    _db.SaveChanges();
                }


                return(Json(permission, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.LogException(User.Identity.Name, ex, "Error While editing Permission (Post)");
                return(null);
            }
        }
Esempio n. 3
0
        public JsonResult EditMenu(MenuViewModel menu)
        {
            try
            {
                var men = _db.Menus.Find(menu.Id);
                if (men != null && men.Status != (int)GeneralEnums.StatusEnum.Deleted)
                {
                    men.ParentId         = menu.ParentId;
                    men.Status           = menu.Status;
                    men.Icon             = menu.Icon;
                    men.PageId           = menu.PageId;
                    men.PageUrl          = menu.PageUrl;
                    men.SortOrder        = menu.SortOrder;
                    _db.Entry(men).State = EntityState.Modified;
                    _db.SaveChanges();


                    var menTrans = _db.MenuTranslations.FirstOrDefault(r => r.MenuId == men.Id && r.LanguageId == menu.LanguageId);
                    if (menTrans != null)
                    {
                        menTrans.Title            = menu.Title;
                        menTrans.Description      = menu.Description;
                        _db.Entry(menTrans).State = EntityState.Modified;
                    }
                    else
                    {
                        menTrans = new MenuTranslation()
                        {
                            MenuId      = men.Id,
                            Description = menu.Description,
                            IsDefault   = false,
                            LanguageId  = menu.LanguageId,
                            Title       = menu.Title
                        };
                        _db.MenuTranslations.Add(menTrans);
                    }

                    _db.SaveChanges();
                }


                return(Json(menu, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.LogException(User.Identity.Name, ex, "Error While editing menu (Post)");
                return(null);
            }
        }
Esempio n. 4
0
        public JsonResult EditSMSTemplate(SMSTemplateViewModel smsTemplate)
        {
            try
            {
                var smsTemp = _db.SMSTemplates.Find(smsTemplate.Id);
                if (smsTemp != null && smsTemp.Status != (int)GeneralEnums.StatusEnum.Deleted)
                {
                    smsTemp.Status           = smsTemplate.Status;
                    smsTemp.DefaultLanguage  = smsTemplate.DefaultTemplateLanguage > 0 ? smsTemplate.DefaultTemplateLanguage : CultureHelper.GetDefaultLanguageId();
                    _db.Entry(smsTemp).State = EntityState.Modified;
                    _db.SaveChanges();

                    var tempTrans = _db.SMSTemplateTranslations.FirstOrDefault(r => r.SMSTemplateId == smsTemp.Id && r.LanguageId == smsTemplate.LanguageId);
                    if (tempTrans != null)
                    {
                        tempTrans.Name             = smsTemplate.Name;
                        tempTrans.Description      = smsTemplate.Description;
                        _db.Entry(tempTrans).State = EntityState.Modified;
                    }
                    else
                    {
                        tempTrans = new SMSTemplateTranslation()
                        {
                            SMSTemplateId = smsTemp.Id,
                            Description   = smsTemplate.Description,
                            LanguageId    = smsTemplate.LanguageId,
                            IsDefault     = false,
                            Name          = smsTemplate.Name
                        };
                        _db.SMSTemplateTranslations.Add(tempTrans);
                    }

                    _db.SaveChanges();
                }


                return(Json(smsTemplate, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.LogException(User.Identity.Name, ex, "Error While editing SMS (Post)");
                return(null);
            }
        }
Esempio n. 5
0
        public JsonResult EditDepartment(DepartmentViewModel department)
        {
            try
            {
                var depa = _db.Departments.Find(department.Id);
                if (depa != null && depa.Status != (int)GeneralEnums.StatusEnum.Deleted)
                {
                    depa.Status           = department.Status;
                    _db.Entry(depa).State = EntityState.Modified;
                    _db.SaveChanges();


                    var depTrans = _db.DepartmentTranslations.FirstOrDefault(r => r.DepartmentId == depa.Id && r.LanguageId == department.LanguageId);
                    if (depTrans != null)
                    {
                        depTrans.Name             = department.Name;
                        depTrans.Description      = department.Description;
                        _db.Entry(depTrans).State = EntityState.Modified;
                    }
                    else
                    {
                        depTrans = new DepartmentTranslation()
                        {
                            DepartmentId = depa.Id,
                            Description  = department.Description,
                            IsDefault    = false,
                            LanguageId   = department.LanguageId,
                            Name         = department.Name
                        };
                        _db.DepartmentTranslations.Add(depTrans);
                    }

                    _db.SaveChanges();
                }


                return(Json(department, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.LogException(User.Identity.Name, ex, "Error While editing Department (Post)");
                return(null);
            }
        }
        public ActionResult EditSystemSetting(SettingViewModel systemSettingViewModel)
        {
            try
            {
                var systemSetting = _db.SystemSettings.Find(systemSettingViewModel.Id);
                if (systemSetting != null && systemSetting.Status != (int)GeneralEnums.StatusEnum.Deleted)
                {
                    systemSetting.Status           = systemSettingViewModel.Status;
                    _db.Entry(systemSetting).State = EntityState.Modified;
                    _db.SaveChanges();

                    var systemSettingTran = _db.SystemSettingTranslations.FirstOrDefault(r => r.LanguageId == systemSettingViewModel.LanguageId && r.SettingId == systemSettingViewModel.Id);
                    if (systemSettingTran != null)
                    {
                        systemSettingTran.Value            = systemSettingViewModel.Value;
                        _db.Entry(systemSettingTran).State = EntityState.Modified;
                    }
                    else
                    {
                        var systemTran = new SystemSettingTranslation()
                        {
                            Name       = systemSettingViewModel.Name,
                            Value      = systemSettingViewModel.Value,
                            LanguageId = systemSettingViewModel.LanguageId,
                            IsDefault  = false,
                            SettingId  = systemSetting.Id,
                        };
                        _db.SystemSettingTranslations.Add(systemTran);
                    }
                    _db.SaveChanges();
                }
                return(Json(systemSettingViewModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.LogException(User.Identity.Name, ex, "Error While Editing System Settings (Post)");
                return(null);
            }
        }
        public ActionResult EditMasterLookup(MasterLookupViewModel masterLookupViewModel)
        {
            try
            {
                var masterLookup = _db.MasterLookups.Find(masterLookupViewModel.Id);
                if (masterLookup != null && masterLookup.Status != (int)GeneralEnums.StatusEnum.Deleted)
                {
                    masterLookup.Status           = masterLookupViewModel.Status;
                    _db.Entry(masterLookup).State = EntityState.Modified;
                    _db.SaveChanges();

                    var masterTran = _db.MasterLookupTranslations.FirstOrDefault(r => r.LanguageId == masterLookupViewModel.LanguageId && r.MasterLookupId == masterLookupViewModel.Id);
                    if (masterTran != null)
                    {
                        masterTran.Name             = masterLookupViewModel.Name;
                        _db.Entry(masterTran).State = EntityState.Modified;
                    }
                    else
                    {
                        var masterLookupTran = new MasterLookupTranslation()
                        {
                            Name           = masterLookupViewModel.Name,
                            LanguageId     = masterLookupViewModel.LanguageId,
                            IsDefault      = false,
                            MasterLookupId = masterLookup.Id
                        };
                        _db.MasterLookupTranslations.Add(masterLookupTran);
                    }
                    _db.SaveChanges();
                }

                return(Json(masterLookupViewModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.LogException(User.Identity.Name, ex, "Error While Editing Master Lookup (Get)");
                return(null);
            }
        }
Esempio n. 8
0
        public ActionResult EditDetailsLookup(DetailsLookupViewModel DetailsLookupViewModel)
        {
            try
            {
                var detailsLookup = _db.DetailsLookups.Find(DetailsLookupViewModel.Id);
                if (detailsLookup != null && detailsLookup.Status != (int)GeneralEnums.StatusEnum.Deleted)
                {
                    detailsLookup.Status           = DetailsLookupViewModel.Status;
                    _db.Entry(detailsLookup).State = EntityState.Modified;
                    _db.SaveChanges();

                    var DetailsTran = _db.DetailsLookupTranslations.FirstOrDefault(r => r.LanguageId == DetailsLookupViewModel.LanguageId && r.DetailsLookupId == DetailsLookupViewModel.Id);
                    if (DetailsTran != null)
                    {
                        DetailsTran.Value            = DetailsLookupViewModel.Name;
                        _db.Entry(DetailsTran).State = EntityState.Modified;
                    }
                    else
                    {
                        var detailsLookupTran = new DetailsLookupTranslation()
                        {
                            Value           = DetailsLookupViewModel.Name,
                            LanguageId      = DetailsLookupViewModel.LanguageId,
                            IsDefault       = false,
                            DetailsLookupId = detailsLookup.Id
                        };
                        _db.DetailsLookupTranslations.Add(detailsLookupTran);
                    }
                    _db.SaveChanges();
                }

                return(Json(DetailsLookupViewModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.LogException(User.Identity.Name, ex, "Error While Editing Details Lookup (Get)");
                return(null);
            }
        }
 public JsonResult EditPermission(RolePermissionsViewModel permission)
 {
     try
     {
         var role            = _db.AspNetRoles.Find(permission.Id.ToString());
         var rolePermissions = _db.RolePermissions.Where(x => x.RoleId == role.Id);
         foreach (var rolePermission in rolePermissions)
         {
             _db.RolePermissions.Remove(rolePermission);
         }
         _db.SaveChanges();
         if (role != null)
         {
             if (!string.IsNullOrWhiteSpace(permission.RoleName))
             {
                 role.Name = permission.RoleName;
             }
             if (!string.IsNullOrWhiteSpace(permission.RoleFriendlyName))
             {
                 role.FriendlyName = permission.RoleFriendlyName;
             }
             if (!string.IsNullOrWhiteSpace(permission.RoleDescription))
             {
                 role.Description = permission.RoleDescription;
             }
             _db.Entry(role).State = EntityState.Modified;
             var permissions       = permission.Permissions.Split(',');
             var newRolePermission = new RolePermission();
             foreach (var perm in permissions)
             {
                 var permId = int.Parse(perm);
                 var existRolePermission = _db.RolePermissions.Any(x => x.RoleId == role.Id.ToString() && x.PermissionId == permId);
                 if (existRolePermission)
                 {
                     //Role Permission Already Exist
                     continue;
                 }
                 newRolePermission.RoleId       = role.Id;
                 newRolePermission.PermissionId = int.Parse(perm);
                 _db.RolePermissions.Add(newRolePermission);
                 _db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         LogHelper.LogException(User.Identity.Name, ex, "Error While adding Role Permission (Post)");
         return(null);
     }
     return(Json(permission, JsonRequestBehavior.AllowGet));
 }
        public ActionResult Details(CitizenProfileViewModel profile)
        {
            int languageId = CultureHelper.GetCurrentLanguageId(Request.Cookies["_culture"]);

            try
            {
                if (profile.LanguageId == 0)
                {
                    profile.LanguageId = CultureHelper.GetDefaultLanguageId();
                }

                var userProfile = _db.UserProfiles.Find(profile.Id);

                if (userProfile != null)
                {
                    userProfile.GenderLookupId     = profile.GenderLookupId;
                    userProfile.PreferedLanguageId = profile.PrefferdLanguage;
                    userProfile.Birthday           = profile.BirthDay;
                    userProfile.Fax                   = profile.Fax;
                    userProfile.IdNumber              = profile.IdNumber;
                    userProfile.PhoneNumber           = profile.PhoneNumber;
                    userProfile.RegionId              = profile.RegionId;
                    userProfile.CityId                = profile.CityId;
                    userProfile.ProvinceId            = profile.ProvinceId;
                    userProfile.MartialStatusLookupId = profile.MartialStatusLookupId;
                    userProfile.ProfilePhoto          = profile.ProfilePath;
                    userProfile.Mobile                = profile.Mobile;

                    _db.Entry(userProfile).State = EntityState.Modified;
                    _db.SaveChanges();

                    var userProfileTrans = _db.UserProfileTranslations.FirstOrDefault(r =>
                                                                                      r.UserProfileId == userProfile.Id && r.LanguageId == profile.LanguageId);
                    if (userProfileTrans != null)
                    {
                        userProfileTrans.FullName         = profile.FullName;
                        userProfileTrans.Address          = profile.Address;
                        _db.Entry(userProfileTrans).State = EntityState.Modified;
                    }
                    else
                    {
                        userProfileTrans = new UserProfileTranslation()
                        {
                            UserProfileId = userProfile.Id,
                            IsDefault     = false,
                            LanguageId    = profile.LanguageId,
                            FullName      = profile.FullName,
                            Address       = profile.Address,
                        };
                        _db.UserProfileTranslations.Add(userProfileTrans);
                    }
                }

                _db.SaveChanges();
                return(RedirectToAction("Details", new { id = profile.Id }));
            }
            catch (Exception ex)
            {
                LogHelper.LogException(User.Identity.Name, ex, "Error While Updating profile");
            }
            var prefferdLanguage = LookupHelper.GetLookupDetailsByMasterId((int)GeneralEnums.MasterLookupEnums.PrefferdLanguage,
                                                                           Request.Cookies["_culture"]);

            ViewBag.PrefferdLanguage = new SelectList(prefferdLanguage, "Id", "Name", profile.PrefferdLanguage);
            ViewBag.GenderLookupId   =
                new SelectList(
                    LookupHelper.GetLookupDetailsByMasterId((int)GeneralEnums.MasterLookupEnums.Gender,
                                                            Request.Cookies["_culture"]), "Id", "Name");
            ViewBag.MartialStatusLookupId = new SelectList(LookupHelper.GetLookupDetailsByMasterId((int)GeneralEnums.MasterLookupEnums.MartialStatus, Request.Cookies["_culture"]), "Id", "Name", profile.MartialStatusLookupId);
            ViewBag.ProvinceId            = new SelectList(LookupHelper.GetLookupDetailsByMasterId((int)GeneralEnums.MasterLookupEnums.Province, Request.Cookies["_culture"]), "Id", "Name", profile.ProvinceId);
            ViewBag.RegionId = new SelectList(LookupHelper.GetLookupDetailsByMasterId((int)GeneralEnums.MasterLookupEnums.Region, Request.Cookies["_culture"]), "Id", "Name", profile.RegionId);
            ViewBag.CityId   = new SelectList(LookupHelper.GetLookupDetailsByMasterId((int)GeneralEnums.MasterLookupEnums.City, Request.Cookies["_culture"]), "Id", "Name", profile.CityId);

            return(View(profile));
        }
Esempio n. 11
0
        public IHttpActionResult UpdateProfile(ProfileViewModel registerModel)
        {
            AuthenticationHelper.ApiAuthorizationCheck(Request);
            try
            {
                var lang       = Request?.Headers?.AcceptLanguage?.FirstOrDefault()?.Value ?? "ar";
                var languageId = lang == "ar"
                    ? (int)GeneralEnums.LanguageEnum.Arabic
                    : (int)GeneralEnums.LanguageEnum.English;


                var city          = LookupHelper.GetLookupDetailsByCode(registerModel.CityCode)?.Id;
                var gender        = LookupHelper.GetLookupDetailsByCode(registerModel.GenderCode)?.Id;
                var martialStatus = LookupHelper.GetLookupDetailsByCode(registerModel.MartialStatusCode)?.Id;
                var province      = LookupHelper.GetLookupDetailsByCode(registerModel.ProvinceCode)?.Id;


                var userProfile = _db.UserProfiles.FirstOrDefault(r => r.Username == registerModel.Username);
                if (userProfile != null)
                {
                    userProfile.Email                 = registerModel.Email.IsNullOrWhiteSpace() ? userProfile.Email : registerModel.Email;
                    userProfile.Fax                   = registerModel.Fax.IsNullOrWhiteSpace() ? userProfile.Fax : registerModel.Fax;
                    userProfile.IdNumber              = registerModel.IdNumber.IsNullOrWhiteSpace() ? userProfile.IdNumber : registerModel.IdNumber;
                    userProfile.Mobile                = registerModel.Mobile.IsNullOrWhiteSpace() ? userProfile.Mobile : registerModel.Mobile;
                    userProfile.PreferedLanguageId    = registerModel.PrefferdLanguage ?? userProfile.PreferedLanguageId;
                    userProfile.CityId                = city ?? userProfile.CityId;
                    userProfile.DepartmentId          = registerModel.Department ?? userProfile.DepartmentId;
                    userProfile.GenderLookupId        = gender ?? userProfile.GenderLookupId;
                    userProfile.MartialStatusLookupId = martialStatus ?? userProfile.MartialStatusLookupId;
                    userProfile.ProvinceId            = province ?? userProfile.ProvinceId;
                    userProfile.RegionId              = registerModel.RegionId ?? userProfile.RegionId;
                    userProfile.Birthday              = registerModel.BirthDay ?? userProfile.Birthday;
                    userProfile.PhoneNumber           = registerModel.PhoneNumber.IsNullOrWhiteSpace() ? userProfile.PhoneNumber : registerModel.PhoneNumber;
                    userProfile.ProfilePhoto          = registerModel.ProfilePath.IsNullOrWhiteSpace() ? userProfile.ProfilePhoto : registerModel.ProfilePath;
                    var userProfileTrans =
                        _db.UserProfileTranslations.FirstOrDefault(r =>
                                                                   r.UserProfileId == userProfile.Id && r.LanguageId == languageId) ??
                        _db.UserProfileTranslations.FirstOrDefault(r => r.UserProfileId == userProfile.Id);
                    if (userProfileTrans != null)
                    {
                        userProfileTrans.FullName = registerModel.FullName.IsNullOrWhiteSpace()
                            ? userProfileTrans.FullName
                            : registerModel.FullName;
                        userProfileTrans.Address = registerModel.Address.IsNullOrWhiteSpace()
                            ? userProfileTrans.Address
                            : registerModel.Address;
                        _db.Entry(userProfileTrans).State = EntityState.Modified;
                    }
                    _db.Entry(userProfile).State = EntityState.Modified;
                    _db.SaveChanges();
                    if (!registerModel.Password.IsNullOrWhiteSpace())
                    {
                        var user = _db.AspNetUsers.FirstOrDefault(r => r.UserName == registerModel.Username);
                        if (user != null)
                        {
                            UserManager.RemovePassword(user.Id);
                            var updateResult = UserManager.AddPassword(user.Id, registerModel.Password);
                            if (updateResult.Succeeded)
                            {
                                return(Ok(registerModel));
                            }
                        }
                    }
                    else
                    {
                        return(Ok(registerModel));
                    }
                    return(Content(HttpStatusCode.Forbidden, new BaseApiResponse()
                    {
                        StatusCode = HttpStatusCode.Forbidden,
                        Message = "General Error"
                    }));
                }
                else
                {
                    var user = new ApplicationUser {
                        UserName = registerModel.Username, Email = registerModel.Email
                    };
                    var result = UserManager.CreateAsync(user, registerModel.Password);
                    if (result.Result.Succeeded)
                    {
                        var profil = new UserProfile
                        {
                            Fax                   = registerModel.Fax ?? string.Empty,
                            Birthday              = registerModel.BirthDay,
                            CreatedOn             = DateTime.Now,
                            GenderLookupId        = gender,
                            ProvinceId            = province,
                            CityId                = city,
                            RegionId              = registerModel.RegionId,
                            IdNumber              = registerModel.IdNumber ?? string.Empty,
                            PhoneNumber           = registerModel.PhoneNumber ?? string.Empty,
                            Mobile                = registerModel.Mobile ?? string.Empty,
                            MartialStatusLookupId = martialStatus,
                            ManagerId             = registerModel.ManagerId,
                            DepartmentId          = registerModel.Department,
                            PreferedLanguageId    = registerModel.PrefferdLanguage,
                            Status                = (int)GeneralEnums.StatusEnum.Active,
                            Username              = registerModel.Username,
                            Email                 = registerModel.Email
                        };
                        _db.UserProfiles.Add(profil);
                        _db.SaveChanges();

                        var profTrans = new UserProfileTranslation()
                        {
                            Address       = registerModel.Address ?? string.Empty,
                            FullName      = registerModel.FullName,
                            IsDefault     = languageId == CultureHelper.GetDefaultLanguageId(),
                            LanguageId    = languageId,
                            UserProfileId = profil.Id
                        };
                        _db.UserProfileTranslations.Add(profTrans);
                        if (!profTrans.IsDefault)
                        {
                            var profTrans1 = new UserProfileTranslation()
                            {
                                Address       = registerModel.Address ?? string.Empty,
                                FullName      = registerModel.FullName,
                                IsDefault     = true,
                                LanguageId    = CultureHelper.GetDefaultLanguageId(),
                                UserProfileId = profil.Id
                            };
                            _db.UserProfileTranslations.Add(profTrans1);
                        }

                        _db.SaveChanges();
                        registerModel.Id = profil.Id;
                        return(Ok(registerModel));
                    }
                    else
                    {
                        return(Content(HttpStatusCode.Forbidden, new BaseApiResponse()
                        {
                            StatusCode = HttpStatusCode.Forbidden,
                            Message = result.Result.Errors.FirstOrDefault()
                        }));
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogException(Core.Constants.Users.System, ex, Core.Constants.Errors.Apis.ErrorRegister);
                return(Content(HttpStatusCode.InternalServerError, new BaseApiResponse()
                {
                    StatusCode = HttpStatusCode.InternalServerError,
                    Message = Core.Constants.Errors.Apis.ErrorRegister
                }));
            }
        }
Esempio n. 12
0
        public async Task <IHttpActionResult> UploadFile(int id)
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                return(Content(HttpStatusCode.UnsupportedMediaType, new BaseApiResponse()
                {
                    StatusCode = HttpStatusCode.UnsupportedMediaType,
                    Message = Constants.ApiMessages.UnSupported
                }));
            }

            try
            {
                var provider = new MultipartMemoryStreamProvider();
                await Request.Content.ReadAsMultipartAsync(provider);

                var sysFiles = new List <FileResponse>();
                foreach (var file in provider.Contents)
                {
                    var dataStream = await file.ReadAsByteArrayAsync();

                    var sysFile = new SystemFile
                    {
                        CreatedBy  = User.Identity.Name,
                        CreatedOn  = DateTime.Now,
                        Status     = (int)GeneralEnums.StatusEnum.Active,
                        TypeId     = id,
                        FileUrl    = string.Empty,
                        ModifiedBy = User.Identity.Name,
                        ModifiedOn = DateTime.Now
                    };
                    _db.SystemFiles.Add(sysFile);
                    _db.SaveChanges();

                    var extention = Path.GetExtension(file.Headers.ContentDisposition.FileName.Trim('"').Trim('/'));

                    File.WriteAllBytes(
                        HttpContext.Current.Server.MapPath($"~/Document/{id}/{sysFile.Id}{extention}"), dataStream);
                    var setting =
                        SettingHelper.GetOrCreate(Constants.SystemSettings.WebsiteUrl, "http://localhost:61712/");
                    var url = $"{setting.Value}/Document/{id}/{sysFile.Id}{extention}";
                    sysFiles.Add(new FileResponse()
                    {
                        Id         = sysFile.Id,
                        CreatedOn  = sysFile.CreatedOn,
                        TypeId     = sysFile.TypeId,
                        FileUrl    = url,
                        StatusCode = HttpStatusCode.OK,
                        Message    = Constants.ApiMessages.Success
                    });
                    sysFile.FileUrl          = url;
                    _db.Entry(sysFile).State = EntityState.Modified;
                    _db.SaveChanges();

                    var sysFileTrans = new SystemFileTranslation()
                    {
                        Description  = string.Empty,
                        DisplayName  = string.Empty,
                        IsDefault    = true,
                        LanguageId   = CultureHelper.GetDefaultLanguageId(),
                        SystemFileId = sysFile.Id
                    };
                    _db.SystemFileTranslations.Add(sysFileTrans);
                    _db.SaveChanges();
                }
                return(Ok(sysFiles));
            }
            catch (Exception ex)
            {
                LogHelper.LogException(User.Identity.Name, ex, "Error While uploading file!");
                return(Content(HttpStatusCode.InternalServerError, new BaseApiResponse()
                {
                    StatusCode = HttpStatusCode.InternalServerError,
                    Message = Constants.ApiMessages.GeneralError
                }));
            }
        }