示例#1
0
        /// 获取工单类型
        /// <summary>
        /// 获取工单类型
        /// </summary>
        /// <returns></returns>
        private WorkOrderDataSource GetDataSource()
        {
            WorkOrderDataSource?dataSource = null;
            TelNum telModel = TelManage.TelNumList.FirstOrDefault(x => x.AreaCode + x.Tel == SYS_DNIS);

            if (telModel != null)
            {
                dataSource = telModel.DataSource;
            }
            else
            {
                if (SYS_DNIS == "2446")
                {
                    dataSource = WorkOrderDataSource.OSEHotLine;
                }
                else if (SYS_DNIS == "2448")
                {
                    dataSource = WorkOrderDataSource.BitShopLine;
                }
                else
                {
                    dataSource = WorkOrderDataSource.TeleContact;
                }
            }
            return(dataSource.Value);
        }
        public HttpStatusCodeResult PostTelNum(TelNum telNum)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Bad Request"));
            }

            db.TelNum.Add(telNum);
            db.SaveChanges();

            return(new HttpStatusCodeResult(HttpStatusCode.OK, "OK"));
        }
        public HttpStatusCodeResult DeleteTelNum(int id)
        {
            TelNum telNum = db.TelNum.Find(id);

            if (telNum == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Not Found"));
            }

            db.TelNum.Remove(telNum);
            db.SaveChanges();

            return(new HttpStatusCodeResult(HttpStatusCode.OK, "OK"));
        }
示例#4
0
        public async Task <IHttpActionResult> Register(Individual model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var modelErrors = new List <string>();
                    foreach (var modelState in ModelState.Values)
                    {
                        foreach (var modelError in modelState.Errors)
                        {
                            modelErrors.Add(modelError.ErrorMessage);
                        }
                    }
                    return(Content(HttpStatusCode.BadRequest, modelErrors[0].ToString()));
                }

                string phone = model.MobNum.CountryCode.ToString().Trim() + model.MobNum.Num.ToString().Trim();

                if (await _bucket.ExistsAsync(model.EmiratiID))
                {
                    return(Content(HttpStatusCode.Conflict, new Error($"EmiratiId already exists")));
                }
                if (await _bucket.ExistsAsync(model.Email))
                {
                    return(Content(HttpStatusCode.Conflict, new Error($"The e-mail already exists ")));
                }
                if (await _bucket.ExistsAsync(phone))
                {
                    return(Content(HttpStatusCode.Conflict, new Error($"Mobile number already exists")));
                }

                Individual individual = new Individual();
                MobNum     mobNum     = new MobNum();
                mobNum.CountryCode = model.MobNum.CountryCode;
                mobNum.Num         = model.MobNum.Num;

                TelNum telNum = new TelNum();
                telNum.CountryCode = model.MobNum.CountryCode;
                telNum.Num         = model.MobNum.Num;

                AuditInfo auditInfo = new AuditInfo();
                auditInfo.Version        = "1";
                auditInfo.Status         = "true";
                auditInfo.LastChangeDate = DateTime.Now.ToString();
                auditInfo.LastChangeBy   = model.Email;

                List <Roles> lstRoles = new List <Roles>();
                foreach (var role in model.Roles)
                {
                    Roles roles = new Roles();
                    roles.Code = role.Code;
                    roles.Name = role.Name;
                    lstRoles.Add(roles);
                }
                List <Fines> lstFines = new List <Fines>();

                foreach (var fine in model.Fines)
                {
                    Fines fines = new Fines();
                    fines.Amount = fine.Amount;
                    fines.Date   = fine.Date;
                    fines.Remark = fine.Remark;
                    lstFines.Add(fines);
                }
                List <Documents> lstDocuments = new List <Documents>();
                foreach (var document in model.Documents)
                {
                    Documents documents = new Documents();
                    documents.Date = document.Date;
                    documents.Name = document.Name;
                    documents.Path = document.Path;
                    lstDocuments.Add(document);
                }
                List <Vehicles> lstVehicles = new List <Vehicles>();
                foreach (var vehicle in model.Vehicles)
                {
                    Vehicles vehicles = new Vehicles();
                    vehicles.Name  = vehicle.Name;
                    vehicles.Model = vehicle.Model;
                    vehicles.Type  = vehicle.Type;
                    lstVehicles.Add(vehicles);
                }


                Name name = new Name();
                EN   en   = new EN();
                en.FullName = model.Name.EN.FullName;
                name.EN     = en;
                AR ar = new AR();
                ar.FullName = model.Name.EN.FullName;
                name.AR     = ar;
                var eotp = GenerateOtp();
                var motp = GenerateOtp();
                sendEmail.SendOtpViaEmail(model.Email, model.Name.EN.FullName, eotp);
                SendOtpViaMobile(model.MobNum, motp);
                string password      = Guid.NewGuid().ToString("d").Substring(1, 4);
                var    individualDoc = new Document <Individual>()
                {
                    Id      = "individual_" + model.EmiratiID,
                    Content = new Individual
                    {
                        KeyID         = "individual_" + model.EmiratiID,
                        Name          = name,
                        DOB           = model.DOB,
                        Nationality   = model.Nationality,
                        Gender        = model.Gender,
                        Fines         = lstFines,
                        Language      = model.Language,
                        MaritalStatus = model.MaritalStatus,
                        MobNum        = mobNum,
                        AuditInfo     = auditInfo,
                        Vehicles      = lstVehicles,
                        Roles         = lstRoles,
                        TelNum        = model.TelNum,
                        DocType       = model.DocType,
                        Documents     = lstDocuments,
                        Email         = model.Email,
                        Notes         = model.Notes,
                    },
                };

                var result = await _bucket.InsertAsync(individualDoc);

                if (!result.Success)
                {
                    return(Content(HttpStatusCode.InternalServerError, new Error(result.Message)));
                }
                else
                {
                    //sendEmail.SendUserIdAndPassword(model.Email, password);
                    var userDocLogin = new Document <Login>()
                    {
                        Id      = "Login_" + model.Email,
                        Content = new Login
                        {
                            Created_by   = model.Email,
                            Created_on   = DateTime.Now.ToString(),
                            UserId       = model.Email,
                            Password     = password,
                            Pre_language = model.Language,
                            Status       = "A",
                            Type         = "CAST",
                            Role         = "User",
                        },
                    };
                    IBucket _bucketLogin = ClusterHelper.GetBucket(ConfigurationManager.AppSettings.Get("CouchbaseLoginBucket"));
                    var     resultLogin  = await _bucketLogin.InsertAsync(userDocLogin);

                    return(Content(HttpStatusCode.Accepted, result.Document.Id));
                }
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.Forbidden, ex.StackTrace));
            }
        }
示例#5
0
        public async Task <IHttpActionResult> Register(Company model)
        {
            var serializer = new JavaScriptSerializer();

            try
            {
                string keyId        = "company_" + model.Email;
                var    userDocument = _bucket.Query <object>(@"SELECT * From " + _bucket.Name + " where keyID= '" + keyId + "'").ToList();

                if (userDocument.Count > 0)
                {
                    return(Content(HttpStatusCode.Conflict, MessageResponse.Message(HttpStatusCode.Conflict.ToString(), "The e-mail already exists"), new JsonMediaTypeFormatter()));
                }
                if (!ModelState.IsValid)
                {
                    var modelErrors = new List <string>();
                    foreach (var modelState in ModelState.Values)
                    {
                        foreach (var modelError in modelState.Errors)
                        {
                            //modelErrors.Add(modelError.ErrorMessage);
                            modelErrors.Add(modelError.ErrorMessage == "" ? modelError.Exception.Message : modelError.ErrorMessage);
                        }
                    }
                    return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), modelErrors[0].ToString()), new JsonMediaTypeFormatter()));
                }

                var userDocumentPhone = _bucket.Query <object>(@"SELECT * From " + _bucket.Name + " where " + _bucket.Name + ".mobNum.num= '" + model.MobNum.NumM + "'").ToList();

                if (userDocumentPhone.Count > 0)
                {
                    return(Content(HttpStatusCode.Conflict, MessageResponse.Message(HttpStatusCode.Conflict.ToString(), "104-Mobile number already exists"), new JsonMediaTypeFormatter()));
                }

                MobNum mobNum = new MobNum();
                mobNum.CountryCodeM = model.MobNum.CountryCodeM;
                mobNum.NumM         = model.MobNum.NumM;

                TelNum telNum = new TelNum();
                telNum.CountryCodeT = model.TelNum.CountryCodeT;
                telNum.NumT         = model.TelNum.NumT;

                AuditInfo auditInfo = new AuditInfo();
                auditInfo.Version        = "1";
                auditInfo.Status         = "true";
                auditInfo.LastChangeDate = DataConversion.ConvertYMDHMS(DateTime.Now.ToString());;
                auditInfo.LastChangeBy   = model.Email;


                List <Roles> lstRoles = new List <Roles>();

                foreach (var role in model.Roles)
                {
                    Roles roles = new Roles();
                    roles.RoleID = role.RoleID;
                    roles.Link   = role.Link;
                    lstRoles.Add(roles);
                }

                /*List<CompanyRoles> lstRoles = new List<CompanyRoles>();
                 *
                 * foreach (var role in model.Roles)
                 * {
                 *  CompanyRoles roles = new CompanyRoles();
                 *  roles.RoleID = role.RoleID;
                 *  roles.Link = role.Link;
                 *  lstRoles.Add(roles);
                 * }*/

                List <Fines> lstFines = new List <Fines>();

                foreach (var fine in model.Fines)
                {
                    Fines fines = new Fines();
                    fines.FineID   = fine.FineID;
                    fines.DateTime = fine.DateTime;
                    fines.Amount   = fine.Amount;
                    fines.Status   = fine.Status;
                    fines.Remark   = fine.Remark;
                    lstFines.Add(fines);
                }

                List <Documents> lstDocuments = new List <Documents>();

                foreach (var document in model.Documents)
                {
                    Documents addnewDocument = new Documents();
                    addnewDocument.DocumentID = document.DocumentID;
                    addnewDocument.Type       = document.Type;
                    addnewDocument.Version    = document.Version;
                    addnewDocument.ExpDate    = document.ExpDate;
                    addnewDocument.DocStatus  = document.DocStatus;
                    lstDocuments.Add(document);
                }

                List <Vehicles> lstVehicles = new List <Vehicles>();
                foreach (var vehicle in model.Vehicles)
                {
                    Vehicles vehicles = new Vehicles();
                    vehicles.VehicleID = vehicle.VehicleID;
                    vehicles.Make      = vehicle.Make;
                    vehicles.ModelYear = vehicle.ModelYear;
                    vehicles.VehType   = vehicle.VehType;
                    vehicles.Status    = vehicle.Status;
                    lstVehicles.Add(vehicles);
                }

                CompanyAddress address = new CompanyAddress();
                address.City    = model.Address.City;
                address.Zip     = model.Address.Zip;
                address.State   = model.Address.State;
                address.Country = model.Address.Country;

                Line line = new Line();
                line.Line1   = model.Address.Line.Line1;
                line.Line2   = model.Address.Line.Line2;
                address.Line = line;


                FullName fullname = new FullName();

                fullname.En_US = model.fullName.En_US;

                fullname.Ar_SA = model.fullName.Ar_SA;

                var eotp = GenerateOtp();
                var motp = GenerateOtp();
                sendEmail.SendOtpViaEmail(model.Email, fullname.En_US, eotp);

                SendOtpViaMobile(model.MobNum, motp);

                string password   = Guid.NewGuid().ToString("d").Substring(1, 4);
                var    companyDoc = new Document <Company>()
                {
                    Id      = "company_" + model.Email,
                    Content = new Company
                    {
                        KeyID     = "company_" + model.Email,
                        fullName  = fullname,
                        Fines     = lstFines,
                        MobNum    = mobNum,
                        AuditInfo = auditInfo,
                        Vehicles  = lstVehicles,
                        Roles     = lstRoles,
                        TelNum    = model.TelNum,
                        DocType   = model.DocType,
                        Documents = lstDocuments,
                        Email     = model.Email,
                        Address   = address,
                        Website   = model.Website
                    },
                };

                var result = await _bucket.InsertAsync(companyDoc);

                if (!result.Success)
                {
                    return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), result.Message), new JsonMediaTypeFormatter()));
                }
                else
                {
                    return(Content(HttpStatusCode.OK, MessageResponse.Message(HttpStatusCode.OK.ToString(), MessageDescriptions.Add, result.Document.Id), new JsonMediaTypeFormatter()));
                }
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.InternalServerError, MessageResponse.Message(HttpStatusCode.InternalServerError.ToString(), ex.StackTrace), new JsonMediaTypeFormatter()));
            }
        }
示例#6
0
        public async Task <IHttpActionResult> InsertUser(Login model)
        {
            //string ppp = EncryptDecryptString.DecodePasswordToFrom64("MTIzNDU2OTk5");
            try
            {
                if (string.IsNullOrEmpty(model.Name))
                {
                    return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "224-name is required"), new JsonMediaTypeFormatter()));
                }
                if (string.IsNullOrEmpty(model.Email))
                {
                    return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "112-email is required"), new JsonMediaTypeFormatter()));
                }
                if (string.IsNullOrEmpty(model.Password))
                {
                    return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "158-Password is required"), new JsonMediaTypeFormatter()));
                }
                var userDocumentEmail = _bucket.Query <object>(@"SELECT * From " + _bucket.Name + " where email= '" + model.Email + "'  and isActive=true and isActive=true and meta().id like'%login_%'").ToList();
                if (userDocumentEmail.Count > 0)
                {
                    return(Content(HttpStatusCode.Conflict, MessageResponse.Message(HttpStatusCode.Conflict.ToString(), "105-The e-mail already exists"), new JsonMediaTypeFormatter()));
                }
                if (model.MobNum == null)
                {
                    return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "199-mobnum is required"), new JsonMediaTypeFormatter()));
                }
                else
                {
                    if (string.IsNullOrEmpty(model.MobNum.AreaM))
                    {
                        return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "200-areaM is required"), new JsonMediaTypeFormatter()));
                    }
                    if (string.IsNullOrEmpty(model.MobNum.NumM))
                    {
                        return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "201-NumM is required"), new JsonMediaTypeFormatter()));
                    }
                    if (string.IsNullOrEmpty(model.MobNum.CountryCodeM))
                    {
                        return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "202-CountryCodeM is required"), new JsonMediaTypeFormatter()));
                    }
                }
                if (model.Roles == null)
                {
                    return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "203-roles is required"), new JsonMediaTypeFormatter()));
                }
                else
                {
                    if (string.IsNullOrEmpty(model.Roles.PrimaryRole))
                    {
                        return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "204-PrimaryRole is required"), new JsonMediaTypeFormatter()));
                    }
                    if (model.Roles.OtherRoles == null)
                    {
                        return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "205-OtherRoles is required"), new JsonMediaTypeFormatter()));
                    }
                }

                var userDocumentPhone = _bucket.Query <object>(@"SELECT * From " + _bucket.Name + " where " + _bucket.Name + ".mobNum.num= '" + model.MobNum.NumM + "' and isActive=true and meta().id like'%login_%'").ToList();

                if (userDocumentPhone.Count > 0)
                {
                    return(Content(HttpStatusCode.Conflict, MessageResponse.Message(HttpStatusCode.Conflict.ToString(), "Mobile number already exists"), new JsonMediaTypeFormatter()));
                }

                try
                {
                    List <PrevPassword> prevPassword = new List <PrevPassword>();
                    var    loginDocumentId           = "login_" + Guid.NewGuid();
                    MobNum mobNum = new MobNum();
                    mobNum.CountryCodeM = model.MobNum.CountryCodeM;
                    mobNum.NumM         = model.MobNum.NumM;
                    mobNum.AreaM        = model.MobNum.AreaM;
                    TelNum telNum = new TelNum();
                    if (model.TelNum != null)
                    {
                        telNum.CountryCodeT = model.TelNum.CountryCodeT;
                        telNum.NumT         = model.TelNum.NumT;
                        telNum.AreaT        = model.TelNum.AreaT;
                    }
                    var loginDocument = new Document <Login>()
                    {
                        Id      = loginDocumentId,
                        Content = new Login
                        {
                            Lang        = model.Lang,
                            DocType     = "user",
                            Name        = model.Name,
                            PassSetDate = DataConversion.ConvertYMDHMS(DateTime.Now.ToString()),
                            Password    = EncryptDecryptString.EncodePasswordToBase64(model.Password),
                            Email       = model.Email,
                            EmirateId   = model.EmirateId,
                            //Mobile = model.Mobile,
                            MobNum     = mobNum,
                            TelNum     = telNum,
                            Department = model.Department,
                            Roles      = model.Roles,
                            PrevPass   = prevPassword,
                            IsActive   = true,
                            Created_By = model.Email,
                            UserPhoto  = model.UserPhoto,
                            Created_On = DataConversion.ConvertYMDHMS(DateTime.Now.ToString()),
                        },
                    };
                    var result = _bucket.Insert(loginDocument);
                    if (!result.Success)
                    {
                        //_bucket.Remove(loginResult.Document.Content.Email);
                        return(Content(HttpStatusCode.InternalServerError, MessageResponse.Message(HttpStatusCode.InternalServerError.ToString(), result.Message), new JsonMediaTypeFormatter()));
                    }
                    return(Content(HttpStatusCode.OK, MessageResponse.Message(HttpStatusCode.OK.ToString(), MessageDescriptions.Add, result.Document.Content.Email), new JsonMediaTypeFormatter()));
                }
                catch (Exception ex)
                {
                    //_bucket.Remove(result.Document.Id);
                    return(Content(HttpStatusCode.InternalServerError, MessageResponse.Message(HttpStatusCode.InternalServerError.ToString(), ex.Message), new JsonMediaTypeFormatter()));
                }

                //}
                // return Content(HttpStatusCode.OK, MessageResponse.Message(HttpStatusCode.OK.ToString(), MessageDescriptions.Add, result..Id), new JsonMediaTypeFormatter());
                //}
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.InternalServerError, MessageResponse.Message(HttpStatusCode.InternalServerError.ToString(), ex.StackTrace), new JsonMediaTypeFormatter()));
            }
        }
示例#7
0
        public IHttpActionResult EmployeeRegister(Individual model)
        {
            try
            {
                if (model.fullName == null)
                {
                    return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "224-Full name is required"), new JsonMediaTypeFormatter()));
                }
                else
                {
                    if (string.IsNullOrEmpty(model.fullName.Ar_SA) && string.IsNullOrEmpty(model.fullName.En_US))
                    {
                        return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "224-Full name is required"), new JsonMediaTypeFormatter()));
                    }
                }
                // Validate Model
                if (!ModelState.IsValid)
                {
                    var modelErrors = new List <string>();
                    foreach (var modelState in ModelState.Values)
                    {
                        foreach (var modelError in modelState.Errors)
                        {
                            modelErrors.Add(modelError.ErrorMessage == "" ? modelError.Exception.Message : modelError.ErrorMessage);
                        }
                    }
                    return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), modelErrors[0].ToString()), new JsonMediaTypeFormatter()));
                }

                var userDocumentEmail = _bucket.Query <object>(@"SELECT * From " + _bucket.Name + " where email= '" + model.Email + "' and isActive=true").ToList();
                if (userDocumentEmail.Count > 0)
                {
                    return(Content(HttpStatusCode.Conflict, MessageResponse.Message(HttpStatusCode.Conflict.ToString(), "105-The e-mail already exists"), new JsonMediaTypeFormatter()));
                }

                if (model.LoginDetails != null)
                {
                    if (string.IsNullOrEmpty(model.LoginDetails.Password))
                    {
                        return(Content(HttpStatusCode.BadRequest, MessageResponse.Message(HttpStatusCode.BadRequest.ToString(), "158-Password is required"), new JsonMediaTypeFormatter()));
                    }
                }

                var userDocumentPhone = _bucket.Query <object>(@"SELECT * From " + _bucket.Name + " where " + _bucket.Name + ".mobNum.num= '" + model.MobNum.NumM + "'").ToList();

                if (userDocumentPhone.Count > 0)
                {
                    return(Content(HttpStatusCode.Conflict, MessageResponse.Message(HttpStatusCode.Conflict.ToString(), "Mobile number already exists"), new JsonMediaTypeFormatter()));
                }

                Address address = new Address();
                address.City    = model.Address.City;
                address.State   = model.Address.State;
                address.Area    = model.Address.Area;
                address.Street  = model.Address.Street;
                address.BldgNum = model.Address.BldgNum;
                address.FlatNum = model.Address.FlatNum;

                MobNum mobNum = new MobNum();
                mobNum.CountryCodeM = model.MobNum.CountryCodeM;
                mobNum.NumM         = model.MobNum.NumM;
                mobNum.AreaM        = model.MobNum.AreaM;

                TelNum telNum = new TelNum();
                if (model.TelNum != null)
                {
                    telNum.CountryCodeT = model.TelNum.CountryCodeT;
                    telNum.NumT         = model.TelNum.NumT;
                    telNum.AreaT        = model.TelNum.AreaT;
                }

                List <AuditInfo> lstauditInfo = new List <AuditInfo>();
                AuditInfo        auditInfo    = new AuditInfo();
                auditInfo.Version        = "1";
                auditInfo.Status         = "true";
                auditInfo.LastChangeDate = DataConversion.ConvertYMDHMS(DateTime.Now.ToString());
                auditInfo.LastChangeBy   = model.Email;
                lstauditInfo.Add(auditInfo);

                List <Roles> lstRoles = new List <Roles>();
                if (model.Roles != null)
                {
                    foreach (var role in model.Roles)
                    {
                        Roles roles = new Roles();
                        roles.RoleID = role.RoleID;
                        roles.Name   = role.Name;
                        roles.Link   = role.Link;
                        lstRoles.Add(roles);
                    }
                }

                #region MyRegion
                List <Fines>        lstFines        = new List <Fines>();
                List <Documents>    lstDocuments    = new List <Documents>();
                List <Vehicles>     lstVehicles     = new List <Vehicles>();
                List <Incidents>    lstIncident     = new List <Incidents>();
                List <ScoreCards>   lstScoreCard    = new List <ScoreCards>();
                List <DriverStatus> lstdriverStatus = new List <DriverStatus>();
                #endregion

                FullName fullName = new FullName();
                fullName.En_US = model.fullName.En_US;
                fullName.Ar_SA = model.fullName.Ar_SA;

                Status status = new Status();
                if (model.Status != null)
                {
                    status.StatusID = model.Status.StatusID;
                    status.DateTime = model.Status.DateTime;
                }



                //DataConversion.ConvertYMDHMS(DateTime.Now.AddDays(Convert.ToInt16(ConfigurationManager.AppSettings.Get("ValidToProfilePhotoDays"))).ToString())
                ProfilePhoto profilePhoto = new ProfilePhoto();
                if (model.ProfilePhoto != null)
                {
                    profilePhoto.DocFormat = model.ProfilePhoto.DocFormat;
                    profilePhoto.Photo     = model.ProfilePhoto.Photo;
                    profilePhoto.ValidFrom = DataConversion.ConvertYMDHMS(DateTime.Now.ToString());
                    profilePhoto.ValidTo   = DataConversion.ConvertYMDHMS(DateTime.Now.AddDays(Convert.ToInt16(ConfigurationManager.AppSettings.Get("ValidToProfilePhotoDays"))).ToString());
                }
                string docId = string.Empty;
                if (string.IsNullOrEmpty(model.KeyID))
                {
                    docId = "individual_" + Guid.NewGuid();
                }
                else
                {
                    docId = "individual_" + model.KeyID;
                }

                var employeeDoc = new Document <Individual>()
                {
                    Id      = docId,
                    Content = new Individual
                    {
                        KeyID         = docId,
                        fullName      = fullName,
                        DOB           = DataConversion.ConvertDateYMD(model.DOB),
                        Nationality   = model.Nationality,
                        Gender        = model.Gender,
                        Fines         = lstFines,
                        Language      = model.Language,
                        MaritalStatus = model.MaritalStatus,
                        MobNum        = mobNum,
                        AuditInfo     = lstauditInfo,
                        Vehicles      = lstVehicles,
                        Roles         = lstRoles,
                        TelNum        = telNum,
                        DocType       = ("Individual").ToLower(),
                        Documents     = lstDocuments,
                        Email         = model.Email,
                        ProfilePhoto  = profilePhoto,
                        Notes         = model.Notes,
                        ScoreCards    = lstScoreCard,
                        Address       = address,
                        Religion      = model.Religion,
                        Status        = status,
                        Incidents     = lstIncident,
                        DriverStatus  = lstdriverStatus,
                    },
                };
                var result = _bucket.Insert(employeeDoc);
                if (!result.Success)
                {
                    return(Content(HttpStatusCode.InternalServerError, MessageResponse.Message(HttpStatusCode.InternalServerError.ToString(), result.Message), new JsonMediaTypeFormatter()));
                }
                return(Content(HttpStatusCode.OK, MessageResponse.Message(HttpStatusCode.OK.ToString(), MessageDescriptions.Add, result.Document.Id), new JsonMediaTypeFormatter()));
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.InternalServerError, MessageResponse.Message(HttpStatusCode.InternalServerError.ToString(), ex.StackTrace), new JsonMediaTypeFormatter()));
            }
        }