Beispiel #1
0
        public static void SaveActivityProposal(QuiGigAPIEntities context, string message, string fromUserId, string toUserId, string activityType, long jobId, string userType, bool isNotification, bool isRead, long proposalId)
        {
            Activity activity = new Activity();

            activity.Message        = message;
            activity.FromID         = fromUserId;
            activity.ToID           = toUserId;
            activity.ActivityType   = activityType;
            activity.ProposalId     = proposalId;
            activity.JobId          = jobId;
            activity.IsNotification = isNotification;
            if (activityType == ProfileParameterEnum.SIGNUP.ToString())
            {
                activity.RedirectPath = "#";
            }
            else if (proposalId > 0)
            {
                activity.RedirectPath = "/order-detail?key=" + Encrypt(userType) + "&param1=" + jobId + "&param2=" + proposalId;
            }
            else
            {
                activity.RedirectPath = "/order-detail?key=" + Encrypt(userType) + "&param1=" + jobId;
            }
            activity.IsRead      = false;
            activity.IsActive    = true;
            activity.IsDelete    = false;
            activity.CreatedDate = DateTime.UtcNow;
            activity.UpdatedDate = DateTime.UtcNow;
            context.Activities.Add(activity);
            context.SaveChanges();
        }
Beispiel #2
0
 public static void SaveUserWallet(QuiGigAPIEntities context, string userId, long userPaymentId, string description, int creditAmount, int debitAmount, long packgId, string paymentStatus, string paymentFrom, decimal payAmount, int bonusCoin, string paymentGateway)
 {
     try
     {
         UserWallet entity = new UserWallet();
         entity.UserID        = userId;
         entity.UserPaymentId = userPaymentId;
         entity.Description   = description;
         entity.CreditAmount  = creditAmount;
         entity.DebitAmount   = debitAmount;
         entity.CreatedDate   = DateTime.UtcNow;
         entity.PaymentFrom   = paymentFrom;
         entity.PaymentStatus = paymentStatus;
         entity.PayAmount     = payAmount;
         entity.BonusCoin     = bonusCoin;
         if (packgId > 0)
         {
             entity.PackageId = packgId;
         }
         entity.PaymentGateway = paymentGateway;
         context.UserWallets.Add(entity);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
     }
 }
        public IHttpActionResult ChangeNotification(ChangeNotificationModel model)
        {
            bool status  = false;
            var  message = "";

            if (!ModelState.IsValid)
            {
                var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Value.Errors }).FirstOrDefault();
                message = errors.Errors[0].ErrorMessage;
            }
            else
            {
                try
                {
                    var query = context.UserNotifications.Where(x => x.ID == model.ID && x.UserId == model.UserId && x.IsActive == true && x.IsDelete == false).FirstOrDefault();
                    if (query != null)
                    {
                        query.NotificationValue = model.DefaultValue;
                        query.UpdatedDate       = DateTime.UtcNow;
                        query.UpdatedByID       = model.UserId;
                        context.SaveChanges();
                        status  = true;
                        message = "Update Successfully.";
                    }
                }
                catch (Exception ex)
                {
                    status  = false;
                    message = ex.Message;
                }
            }
            return(Ok(new
            {
                Success = status,
                Message = message
            }));
        }
        public IHttpActionResult SaveMessage(MessageListModel model)
        {
            bool success       = false;
            var  message       = "";
            var  fromUser      = "";
            var  fromUserImage = "";
            var  toUser        = "";
            var  toUserImage   = "";

            try
            {
                Message entity = new Message();
                entity.MessageText = model.MessageText;
                entity.FromID      = model.UserId;
                entity.ToID        = model.ToID;
                entity.JobID       = model.JobID;
                entity.GroupId     = model.GroupId;
                entity.IsRead      = model.IsRead;
                entity.IsActive    = true;
                entity.IsDelete    = false;
                entity.CreatedDate = DateTime.UtcNow;
                context.Messages.Add(entity);
                context.SaveChanges();
                success = true;
                message = "Save successfully.";

                var fromUserDeatil = context.UserDetails.Where(x => x.UserID == model.UserId).FirstOrDefault();
                fromUser      = fromUserDeatil.FirstName;
                fromUserImage = fromUserDeatil.ProfilePic == null ? "/Content/images/profile-progress-avtar.svg" : fromUserDeatil.ProfilePic;

                var toUserDeatil = context.UserDetails.Where(x => x.UserID == model.ToID).FirstOrDefault();
                toUser      = toUserDeatil.FirstName;
                toUserImage = toUserDeatil.ProfilePic == null ? "/Content/images/profile-progress-avtar.svg" : toUserDeatil.ProfilePic;
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return(Ok(new
            {
                Success = success,
                Message = message,
                FromUserName = fromUser,
                FromUserID = model.UserId,
                FromUserImage = fromUserImage,
                ToUserName = toUser,
                ToUserImage = toUserImage
            }));
        }
Beispiel #5
0
        public static long SaveUserPayment(QuiGigAPIEntities context, string userId, string provider, long planID, decimal durationAmount, string description, string token, string transactionId, long packgId, string paymentFrom, string paymentStatus)
        {
            long id = 0;

            try
            {
                var providerDetail = context.PaymentSubscriptions.Where(x => x.Provider.ToLower() == provider.ToLower() && x.IsActive == true).FirstOrDefault();
                if (providerDetail != null)
                {
                    UserPayment entity = new UserPayment();
                    entity.ProviderId = providerDetail.ID;
                    entity.UserID     = userId;
                    if (planID > 0)
                    {
                        entity.UserPlanId = planID;
                    }
                    entity.Token         = token;
                    entity.Amount        = durationAmount;
                    entity.PaymentStatus = paymentStatus;
                    entity.PaymentFrom   = paymentFrom;
                    if (!string.IsNullOrEmpty(transactionId))
                    {
                        entity.TransactionId = transactionId;
                    }
                    entity.CreatedDate = DateTime.UtcNow;
                    entity.Description = description;
                    if (packgId > 0)
                    {
                        entity.PackageId = packgId;
                    }
                    context.UserPayments.Add(entity);
                    context.SaveChanges();
                    id = entity.ID;
                }
            }
            catch (Exception ex)
            {
            }
            return(id);
        }
        public async Task <IHttpActionResult> SaveOrderForm(ServiceModel model)
        {
            bool success   = false;
            var  messsage  = "";
            long jobId     = 0;
            var  manager   = HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var  userExist = manager.FindById(model.UserId);

            if (userExist != null)
            {
                if (userExist.EmailConfirmed)
                {
                    var userDetail       = context.UserDetails.Where(x => x.UserID == model.UserId).FirstOrDefault();
                    var featurePostOrder = context.Features.Where(x => x.UniqueCode == "POST_ORDER").FirstOrDefault();
                    var featureVal       = featurePostOrder.PlanDurationFeatures.FirstOrDefault();
                    if (userDetail.BidPoints >= Convert.ToInt32(featureVal.FeatureValue))
                    {
                        Util.SaveUserWallet(context, model.UserId, 0, "Post Order", 0, Convert.ToInt32(featureVal.FeatureValue), 0, PaymentStatus.Completed.ToString(), PaymentFromSite.QuiGig.ToString(), 0, 0, "Post Gig");
                        try
                        {
                            if (model.OptionList.Count() > 0)
                            {
                                #region Save Jobs
                                var parmSett    = context.ParameterSettings.Where(x => x.UniqueName == ParameterUniqueNameEnum.BID_TIMER.ToString() && x.IsActive == true && x.IsDelete == false).FirstOrDefault();
                                var serviceName = context.Services.Where(x => x.ID == model.ServiceID && x.IsActive == true && x.IsDelete == false).FirstOrDefault();
                                Job job         = new Job();
                                job.ServiceID = model.ServiceID;
                                if (!string.IsNullOrEmpty(model.UserId))
                                {
                                    job.UserID = model.UserId;
                                }
                                job.JobTitle  = serviceName.ServiceName;
                                job.JobStatus = 1;
                                if (parmSett != null)
                                {
                                    int totalTime = Convert.ToInt32(parmSett.Value) + 5;
                                    if (parmSett.ValueType == ValueTypeEnum.Hourly.ToString())
                                    {
                                        job.JobExpireDate = DateTime.UtcNow.AddHours(totalTime).AddMinutes(30);
                                    }
                                    else if (parmSett.ValueType == ValueTypeEnum.Monthly.ToString())
                                    {
                                        job.JobExpireDate = DateTime.UtcNow.AddMonths(Convert.ToInt32(parmSett.Value));
                                    }
                                    else if (parmSett.ValueType == ValueTypeEnum.Yearly.ToString())
                                    {
                                        job.JobExpireDate = DateTime.UtcNow.AddYears(Convert.ToInt32(parmSett.Value));
                                    }
                                    else
                                    {
                                        job.JobExpireDate = DateTime.UtcNow.AddDays(Convert.ToInt32(parmSett.Value));
                                    }
                                }
                                job.IsActive    = true;
                                job.IsDelete    = false;
                                job.IsPublish   = false;
                                job.CreatedDate = DateTime.UtcNow;
                                job.UpdatedDate = DateTime.UtcNow;
                                job.StateName   = model.StateName;
                                job.CityName    = model.CityName;
                                context.Jobs.Add(job);
                                context.SaveChanges();
                                #endregion
                                #region Save Options
                                foreach (var optionList in model.OptionList)
                                {
                                    JobQuestionOption jobQuesOption = new JobQuestionOption();
                                    jobQuesOption.OptionID    = optionList.OptionID;
                                    jobQuesOption.OtherAnswer = optionList.OtherAnswer;
                                    jobQuesOption.JobID       = job.ID;
                                    jobQuesOption.CreatedDate = DateTime.UtcNow;
                                    context.JobQuestionOptions.Add(jobQuesOption);
                                    context.SaveChanges();
                                    //if (optionList.FileUploadList != null)
                                    //{
                                    //    foreach (var fileList in optionList.FileUploadList)
                                    //    {
                                    //        JobOptionAttachment jobAttachment = new JobOptionAttachment();
                                    //        jobAttachment.JobQuestionOptionsID = jobQuesOption.ID;
                                    //        jobAttachment.OriginalName = fileList.OriginalName;
                                    //        jobAttachment.NewName = fileList.NewName;
                                    //        jobAttachment.Path = fileList.Path;
                                    //        jobAttachment.Description = fileList.Description;
                                    //        jobAttachment.AttachmentExt = fileList.AttachmentExt;
                                    //        jobAttachment.AttachmentType = fileList.AttachmentType;
                                    //        jobAttachment.AttachmentSize = fileList.AttachmentSize;
                                    //        jobAttachment.CreatedDate = DateTime.UtcNow;
                                    //        context.JobOptionAttachments.Add(jobAttachment);
                                    //        context.SaveChanges();
                                    //    }
                                    //}
                                }
                                #endregion

                                #region Save Activity and Email send

                                Util.SaveActivity(context, "New Gigs: " + job.JobTitle, model.UserId, model.UserId, ActivityType.PostedJob.ToString(), job.ID, "Customer", true, false);
                                //await UpdateJob(model.ServiceID, model.CityName, model.StateName, model.UserId, job.JobTitle, job.ID);
                                //var userService = context.UserServices.Where(x => x.ServiceID == model.ServiceID).ToList();

                                //foreach (var activity in userService)
                                //{
                                //    if (model.UserId != activity.UserID)
                                //    {
                                //        if (!string.IsNullOrEmpty(model.CityName) && !string.IsNullOrEmpty(model.StateName))
                                //        {
                                //            var userAddress = context.UserAddresses.Where(x => x.City.ToLower() == model.CityName.ToLower() && x.State.ToLower() == model.StateName.ToLower() && x.UserID == activity.UserID).FirstOrDefault();
                                //            if (userAddress != null)
                                //            {
                                //                var toUserExist = UserManager.FindById(activity.UserID);
                                //                if (toUserExist.EmailConfirmed)
                                //                {
                                //                    //check sp push notification setting
                                //                    var isPushNotify = Util.GetNotificationValue(NotificationEnum.MATCHING_ORDERS.ToString(), Convert.ToString(NotificationCategoryEnum.PUSH_NOTIFICATION), activity.UserID, context);

                                //                    Util.SaveActivity(context, "New Gig: " + job.JobTitle, model.UserId, activity.UserID, ActivityType.PostedJob.ToString(), job.ID, "ServiceProvider", isPushNotify, false);
                                //                    //check sp email notification setting
                                //                    bool isEmailNotify = Util.GetNotificationValue(NotificationEnum.MATCHING_ORDERS.ToString(), NotificationCategoryEnum.EMAIL_NOTIFICATION.ToString(), activity.UserID, context);
                                //                    if (isEmailNotify)
                                //                    {
                                //                        var fromUserExist = UserManager.FindById(model.UserId);

                                //                        if (fromUserExist != null && toUserExist != null)
                                //                        {
                                //                            var fromUserDetail = context.UserDetails.Where(x => x.UserID == fromUserExist.Id).FirstOrDefault();
                                //                            var toUserDetail = context.UserDetails.Where(x => x.UserID == toUserExist.Id).FirstOrDefault();

                                //                            #region Email Sending Code
                                //                            try
                                //                            {
                                //                                string emailBody = CommonLib.GetEmailTemplateValue("PostNewJob/Body");
                                //                                string emailSubject = "QuiGig - New matching order";
                                //                                string strFromEmailAddress = ConfigurationManager.AppSettings["FromAddress"].ToString();
                                //                                var path = Request.RequestUri.Scheme + "://" + Request.RequestUri.Authority;
                                //                                emailBody = emailBody.Replace("@@@Path", path);
                                //                                emailBody = emailBody.Replace("@@@JobTitle", job.JobTitle);
                                //                                emailBody = emailBody.Replace("@@@FromUserName", fromUserDetail.FirstName);
                                //                                emailBody = emailBody.Replace("@@@ToUserName", toUserDetail.FirstName);
                                //                                CommonLib.SendMail(strFromEmailAddress, toUserExist.Email, emailSubject, emailBody);
                                //                            }
                                //                            catch (Exception ex)
                                //                            {
                                //                                messsage = ex.Message;
                                //                            }
                                //                            #endregion
                                //                        }
                                //                    }
                                //                }
                                //            }
                                //        }
                                //    }
                                //}

                                #endregion

                                jobId    = job.ID;
                                success  = true;
                                messsage = "Save successfully.";
                            }
                        }
                        catch (Exception ex)
                        {
                            messsage = ex.Message;
                        }
                    }
                    else
                    {
                        #region Save Jobs
                        var parmSett    = context.ParameterSettings.Where(x => x.UniqueName == ParameterUniqueNameEnum.BID_TIMER.ToString() && x.IsActive == true && x.IsDelete == false).FirstOrDefault();
                        var serviceName = context.Services.Where(x => x.ID == model.ServiceID && x.IsActive == true && x.IsDelete == false).FirstOrDefault();
                        Job job         = new Job();
                        job.ServiceID = model.ServiceID;
                        if (!string.IsNullOrEmpty(model.UserId))
                        {
                            job.UserID = model.UserId;
                        }
                        job.JobTitle  = serviceName.ServiceName;
                        job.JobStatus = 1;
                        if (parmSett != null)
                        {
                            int totalTime = Convert.ToInt32(parmSett.Value) + 5;
                            if (parmSett.ValueType == ValueTypeEnum.Hourly.ToString())
                            {
                                job.JobExpireDate = DateTime.UtcNow.AddHours(totalTime).AddMinutes(30);
                            }
                            if (parmSett.ValueType == ValueTypeEnum.Monthly.ToString())
                            {
                                job.JobExpireDate = DateTime.UtcNow.AddMonths(Convert.ToInt32(parmSett.Value));
                            }
                            if (parmSett.ValueType == ValueTypeEnum.Yearly.ToString())
                            {
                                job.JobExpireDate = DateTime.UtcNow.AddYears(Convert.ToInt32(parmSett.Value));
                            }
                            if (parmSett.ValueType == ValueTypeEnum.Days.ToString())
                            {
                                job.JobExpireDate = DateTime.UtcNow.AddDays(Convert.ToInt32(parmSett.Value));
                            }
                        }
                        job.IsActive    = false;
                        job.IsDelete    = false;
                        job.IsPublish   = false;
                        job.CreatedDate = DateTime.UtcNow;
                        job.UpdatedDate = DateTime.UtcNow;
                        job.StateName   = model.StateName;
                        job.CityName    = model.CityName;
                        context.Jobs.Add(job);
                        context.SaveChanges();
                        #endregion
                        #region Save Options
                        foreach (var optionList in model.OptionList)
                        {
                            JobQuestionOption jobQuesOption = new JobQuestionOption();
                            jobQuesOption.OptionID    = optionList.OptionID;
                            jobQuesOption.OtherAnswer = optionList.OtherAnswer;
                            jobQuesOption.JobID       = job.ID;
                            jobQuesOption.CreatedDate = DateTime.UtcNow;
                            context.JobQuestionOptions.Add(jobQuesOption);
                            context.SaveChanges();
                            if (optionList.FileUploadList != null)
                            {
                                foreach (var fileList in optionList.FileUploadList)
                                {
                                    JobOptionAttachment jobAttachment = new JobOptionAttachment();
                                    jobAttachment.JobQuestionOptionsID = jobQuesOption.ID;
                                    jobAttachment.OriginalName         = fileList.OriginalName;
                                    jobAttachment.NewName        = fileList.NewName;
                                    jobAttachment.Path           = fileList.Path;
                                    jobAttachment.Description    = fileList.Description;
                                    jobAttachment.AttachmentExt  = fileList.AttachmentExt;
                                    jobAttachment.AttachmentType = fileList.AttachmentType;
                                    jobAttachment.AttachmentSize = fileList.AttachmentSize;
                                    jobAttachment.CreatedDate    = DateTime.UtcNow;
                                    context.JobOptionAttachments.Add(jobAttachment);
                                    context.SaveChanges();
                                }
                            }
                        }
                        #endregion
                        jobId    = job.ID;
                        success  = false;
                        messsage = "You have not sufficent coin for post and order.";
                    }
                }
            }
            else
            {
                messsage = "Your email is not confirmed";
            }
            return(Ok(new
            {
                Success = success,
                Message = messsage,
                JobId = jobId
            }));
        }
        public ActionResult UploadProfileImage(UploadFileViewModel model)
        {
            var  path    = "";
            bool success = false;
            var  message = "";

            if (!ModelState.IsValid)
            {
                var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Value.Errors }).FirstOrDefault();
                message = errors.Errors[0].ErrorMessage;
            }
            else
            {
                var httpRequest = HttpContext.Request;
                if (httpRequest.Files.Count > 0)
                {
                    foreach (string file in httpRequest.Files)
                    {
                        var            postedFile            = httpRequest.Files[file];
                        var            ext                   = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf('.'));
                        var            extension             = ext.ToLower();
                        IList <string> AllowedFileExtensions = new List <string> {
                            ".jpg", ".jpeg", ".png", ".bmp", ".gif", ".tif"
                        };
                        if (AllowedFileExtensions.Contains(extension))
                        {
                            var pathExist = HttpContext.Server.MapPath("~/Content/images/UserProfileImages/");
                            if (!Directory.Exists(pathExist))
                            {
                                Directory.CreateDirectory(pathExist);
                            }

                            if (postedFile != null && postedFile.ContentLength > 0)
                            {
                                try
                                {
                                    var userDetail = context.UserDetails.Where(x => x.UserID == model.UserId).FirstOrDefault();
                                    if (userDetail != null)
                                    {
                                        var imgName  = DateTime.Now.Ticks.ToString() + postedFile.FileName;
                                        var filePath = pathExist + imgName;
                                        postedFile.SaveAs(filePath);
                                        path = "/Content/images/UserProfileImages/" + imgName;
                                        userDetail.ProfilePic = path;
                                        context.SaveChanges();
                                        string targetPath = @"C:\inetpub\wwwroot\Content\images\UserProfileImages";
                                        string sourceFile = Path.Combine(filePath, imgName);
                                        string destFile   = Path.Combine(targetPath, imgName);
                                        System.IO.File.Copy(filePath, destFile, true);
                                        System.IO.File.Delete(filePath);
                                        success = true;
                                        message = "Upload Successfully.";
                                    }
                                    else
                                    {
                                        success = false;
                                        message = "User not exist.";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    message = ex.Message;
                                }
                            }
                        }
                        else
                        {
                            success = false;
                            message = "Please Upload image of type";
                        }
                    }
                }
            }
            return(Json(new { Status = success, Message = message, Path = path }, JsonRequestBehavior.AllowGet));
        }
        public async Task <IHttpActionResult> Register(RegisterModel model)
        {
            string currRole = "";

            try
            {
                if (ModelState.IsValid)
                {
                    var user = new ApplicationUser
                    {
                        UserName       = model.Email,
                        Email          = model.Email,
                        EmailConfirmed = false,
                    };
                    var userExist = await UserManager.FindByNameAsync(model.Email);

                    if (userExist != null)
                    {
                        return(Ok(new
                        {
                            Success = false,
                            Message = model.Email + " is already taken.",
                        }));
                    }
                    else
                    {
                        var result = await UserManager.CreateAsync(user, model.Password);

                        if (result.Succeeded)
                        {
                            var userRole      = UserRoleEnum.Customer.ToString();
                            var userEmailCode = RandomStringAndNumeric(6);

                            UserManager.AddToRole(user.Id, userRole);
                            UserDetail userEntity = new UserDetail();
                            userEntity.FirstName        = model.FullName;
                            userEntity.CreatedDate      = DateTime.UtcNow;
                            userEntity.UpdatedDate      = DateTime.UtcNow;
                            userEntity.UserID           = user.Id;
                            userEntity.UserEmailCode    = userEmailCode;
                            userEntity.IsActive         = true;
                            userEntity.IsDelete         = false;
                            userEntity.IsPublish        = true;
                            userEntity.CarryForwordCoin = 0;
                            context.UserDetails.Add(userEntity);
                            context.SaveChanges();

                            var nCount = context.Proc_SetUserDefaultNotifications(user.Id, userRole);

                            if (!string.IsNullOrEmpty(model.City) && !string.IsNullOrEmpty(model.StateName))
                            {
                                var stateDetail = context.StateMasters.Where(x => x.Name.ToLower() == model.StateName.ToLower()).FirstOrDefault();
                                if (stateDetail != null)
                                {
                                    var         cityDetail = context.CityMasters.Where(x => x.Name.ToLower() == model.City.ToLower() && x.StateID == stateDetail.ID).FirstOrDefault();
                                    UserAddress entity     = new UserAddress();
                                    entity.City        = model.City;
                                    entity.CityId      = cityDetail.ID;
                                    entity.State       = stateDetail.Name;
                                    entity.StateId     = stateDetail.ID;
                                    entity.CountryID   = stateDetail.CountryID;
                                    entity.UserID      = user.Id;
                                    entity.IsDraft     = true;
                                    entity.CreatedDate = DateTime.UtcNow;
                                    entity.IsActive    = true;
                                    entity.IsDelete    = false;
                                    entity.UpdatedDate = DateTime.UtcNow;
                                    context.UserAddresses.Add(entity);
                                    context.SaveChanges();
                                }
                            }

                            #region Email Sending Code
                            try
                            {
                                var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                                string emailBody           = CommonLib.GetEmailTemplateValue("VerifyAccount/Body");
                                string emailSubject        = CommonLib.GetEmailTemplateValue("VerifyAccount/Subject");
                                string strFromEmailAddress = ConfigurationManager.AppSettings["FromAddress"].ToString();
                                var    path = Request.RequestUri.Scheme + "://" + Request.RequestUri.Authority;
                                emailBody = emailBody.Replace("@@@Path", path);
                                emailBody = emailBody.Replace("@@@UserName", model.FullName);
                                emailBody = emailBody.Replace("@@@UserEmailCode", userEmailCode);
                                CommonLib.SendMail(strFromEmailAddress, model.Email, emailSubject, emailBody);
                            }
                            catch (Exception ex)
                            {
                                return(Ok(new
                                {
                                    Success = false,
                                    Message = ex.Message
                                }));
                            }
                            #endregion

                            currRole = UserRoleEnum.Customer.ToString();
                            return(Ok(new
                            {
                                Success = true,
                                Message = "You have successfully registered, Please verify your account from registered email.",
                                CurrentRole = currRole,
                                UserName = model.FullName,
                                UserId = user.Id
                            }));
                        }
                        else
                        {
                            return(Ok(new
                            {
                                Success = false,
                                Message = ((string[])(result.Errors))[0]
                            }));
                        }
                    }
                }
                else
                {
                    var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Value.Errors }).FirstOrDefault();
                    var er     = errors.Errors[0].ErrorMessage;
                    return(Ok(new
                    {
                        Success = false,
                        Message = er
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Ok(new
                {
                    Success = false,
                    Message = ex.Message
                }));
            }
        }